父类pom声明版本
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.bppt.version>2.3.3.RELEASE</spring.bppt.version>
</properties>
然后需要打包的子模块添加名称docker.image.prefix
最后所有需要打包的项目再添加下面的依赖
<build>
<finalName>alibaba-cloud-gateway</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}
</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar
</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Spotify 的 docker-maven-plugin 插件是⽤maven插件⽅式构建docker镜像的。
${project.build.finalName} 产出物名称
缺省为 p r o j e c t . a r t i f a c t I d − {project.artifactId}- project.artifactId−{project.version}