- 将依赖包打包到jar中
<!-- 打包依赖包到jar中 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>包名.MainClass类名</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
会生成不包含第三方依赖包的xxxx-version.jar
和包含第三方依赖包的xxxx-version-dependencies.jar
- 将依赖包打包到lib目录中
<!-- 复制依赖包到lib中 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<!--<configuration>-->
<!--<outputDirectory>${project.build.directory}/lib-->
<!--</outputDirectory>-->
<!--</configuration>-->
</execution>
</executions>
</plugin>
会将所有的第三方依赖包复制到太浓目录的lib目录下