Maven首页 Maven常用插件:maven-dependency-plugin的使用及详解

说明:该插件可以把依赖的jar包,打包到项目的指定目录中

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<execution>
			<id>copy-dependencies</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<!-- 拷贝项目依赖包到lib/目录下 -->
				<outputDirectory>${project.build.directory}/lib</outputDirectory>
				<!-- 间接依赖也拷贝 -->
				<excludeTransitive>false</excludeTransitive>
				<!-- 带上版本号 -->
				<stripVersion>false</stripVersion>
			</configuration>
		</execution>
	</executions>
</plugin>

打包后的目录结构如下所示:

Maven常用插件:maven-dependency-plugin的使用及详解-图片-1