<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<configuration>
<mainClass>cui.yao.nan.erureka.EurekaServerApplicationmainClass>
configuration>
plugin>
帮助我们在Maven工程中,通过简单的配置,自动生成镜像并推送到仓库中
使用命令行
使用POM的方式
<plugin>
<groupId>com.spotifygroupId>
<artifactId>docker-maven-pluginartifactId>
<version>1.0.0version>
<configuration>
<imageName>mavendemoimageName>
<baseImage>javabaseImage>
<maintainer>docker_maven [email protected]maintainer>
<workdir>/ROOTworkdir>
<cmd>["java", "-version"]cmd>
<entryPoint>["java", "-jar", "${project.build.finalName}.jar"]entryPoint>
<resources>
<resource>
<targetPath>/ROOTtargetPath>
<directory>${project.build.directory}directory>
<include>${project.build.finalName}.jarinclude>
resource>
resources>
configuration>
plugin>
<plugin>
<groupId>com.spotifygroupId>
<artifactId>docker-maven-pluginartifactId>
<version>1.0.0version>
<configuration>
<imageName>mavendemoimageName>
<dockerDirectory>${basedir}/dockerdockerDirectory>
<resources>
<resource>
<targetPath>/ROOTtargetPath>
<directory>${project.build.directory}directory>
<include>${project.build.finalName}.jarinclude>
resource>
resources>
configuration>
plugin>
FROM java
MAINTAINER docker_maven [email protected]
WORKDIR /ROOT
CMD ["java", "-version"]
ENTRYPOINT ["java", "-jar", "${project.build.finalName}.jar"]
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.1version>
<configuration>
<source>1.8source>
<target>1.8target>
<encoding>UTF-8encoding>
<skipTests>trueskipTests>
<meminitial>128mmeminitial>
<maxmem>512mmaxmem>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jar-pluginartifactId>
<configuration>
<classesDirectory>target/classes/classesDirectory>
<archive>
<manifest>
<mainClass>com.alibaba.dubbo.container.MainmainClass>
<useUniqueVersions>falseuseUniqueVersions>
<addClasspath>trueaddClasspath>
<classpathPrefix>lib/classpathPrefix>
manifest>
<manifestEntries>
<Class-Path>.Class-Path>
manifestEntries>
archive>
<excludes>
<exclude>**/profiles/**exclude>
<exclude>**/jdbc.propertiesexclude>
<exclude>**/*.protoexclude>
excludes>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-source-pluginartifactId>
<executions>
<execution>
<id>attach-sourcesid>
<goals>
<goal>jargoal>
goals>
execution>
executions>
plugin>
<!--最好先指定过如下属性—>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
...
properties>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-shade-pluginartifactId>
<version>3.1.0version>
<executions>
<execution>
<phase>packagephase>
<goals>
<goal>shadegoal>
goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlersresource>
transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemasresource>
transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.chench.MainmainClass>
transformer>
transformers>
configuration>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<executions>
<execution>
<id>unpackid>
<phase>prepare-packagephase>
<goals>
<goal>unpackgoal>
goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.xxxgroupId>
<artifactId>xxx-xxxartifactId>
<version>1.0.0version>
<type>jartype>
<includes>**/*.classincludes>
<overWrite>falseoverWrite>
<outputDirectory>${project.build.directory}/classesoutputDirectory>
artifactItem>
artifactItems>
configuration>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<version>3.0.2version>
<executions>
<execution>
<phase>prepare-packagephase>
<goals>
<goal>copy-dependenciesgoal>
goals>
execution>
executions>
<configuration>
<includeScope>systemincludeScope>
<outputDirectory>${project.build.directory}/classesoutputDirectory>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-dependency-pluginartifactId>
<version>3.0.2version>
<executions>
<execution>
<id>unpackid>
<phase>prepare-packagephase>
<goals>
<goal>unpack-dependenciesgoal>
goals>
execution>
executions>
<configuration>
<includeScope>systemincludeScope>
<outputDirectory>${project.build.directory}/classesoutputDirectory>
configuration>
plugin>
<resources>
<resource>
<directory>src/main/resourcesdirectory>
<excludes>
<exclude>**/*.svnexclude>
excludes>
resource>
<resource>
<directory>src/main/resources/profiles/${profile.dir}directory>
<includes>
<include>*.propertiesinclude>
includes>
resource>
resources>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-javadoc-pluginartifactId>
<version>2.10.2version>
<configuration>
<aggregate>trueaggregate>
configuration>
<executions>
<execution>
<id>attach-javadocsid>
<goals>
<goal>jargoal>
goals>
execution>
executions>
plugin>
<artifactId>maven-pmd-pluginartifactId>
<artifactId>maven-checkstyle-pluginartifactId>