Skip to content

Instantly share code, notes, and snippets.

@gjp0609
Created January 21, 2019 09:08
Show Gist options
  • Save gjp0609/9fe2e7c1bdd3bc72490f54fddc4653ec to your computer and use it in GitHub Desktop.
Save gjp0609/9fe2e7c1bdd3bc72490f54fddc4653ec to your computer and use it in GitHub Desktop.
打包时排除lib
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<!--此处修改为你的应用入口类全路径-->
<mainClass>com.xxx.xxxxx.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<!--这个插件就是把依赖的jar包复制出来放到编译后的target/lib目录,并且在打包时候排除内部依赖-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment