mavn打包跳过测试
mvn clean install -Dmaven.test.skip=true
maven安装本地jar
# -Dfile=jar包在本地的位置
# -DgroupId=坐标中的groupId
# -DartifactId=坐标中的artifactId
# -Dversion=坐标中的version
mvn install:install-file -Dfile=D:\sqljdbc6-4.2.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc6 -Dversion=4.2 -Dpackaging=jar
maven 打包 需要 lib下的jar
可以在pom文件中指定jar路径
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
打包设置 settings文件
这是我再 mvn install 的时候,出现的问题
由于我的 IDEA 全局配置的 settings 是 aliyun 的仓库,我当前的项目配置的私服的仓库,mvn install 就会出现问题,从上面的报错信息看,他是从全局配置的仓库中 找 jar 去了,而我现在用的私服,这种问题的解决办法就是 mvn install 指定 settings 文件
mvn install --settings D:\maven\apache-maven-3.5.3\conf\settings-gjyun.xml
maven插件制作docker镜像
在 pom.xml 中加入插件
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- docker的maven插件,官网: https://github.com/spotify/docker-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<!-- registry 私有仓库地址 -->
<imageName>192.168.100.3:5000/${project.artifactId}:${project.version}</imageName>
<!-- 制作镜像需要依赖 jdk 的镜像 -->
<baseImage>jdk1.8</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<!-- docker 地址 需要开启远程访问 -->
<dockerHost>http://192.168.100.3:2375</dockerHost>
</configuration>
</plugin>
</plugins>
</build>
docker 开启远程访问
vi /lib/systemd/system/docker.service
ExecStart=后面添加以下内容:
-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
这只是我的:
或者
做成镜像上传到 registry 私有仓库
在模块的命令行:
mvn clean package docker:build -DpushImage