maven 从pom.xml 下载jar包到本地

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011561335/article/details/80322960

时至今日,maven已经是每个开发人员必备的工具了。而有些情况我们需要把jar下载到本地使用。

下面就说一下怎么通过pom下载jar包到本地。

直接上干货。

第一步:创建一个pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>Spider</groupId>
	<artifactId>Spider</artifactId>
	<version>1.0</version>

	<dependencies>
		<!-- https://mvnrepository.com/artifact/junit/junit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>

	</dependencies>
</project>

第二步:创建update.bat文件

mvn dependency:copy-dependencies

直接双击运行,即可下载pom中引用的jar到当前目录的taget目录下。


附记:配置下载目录


<plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <excludeTransitive>false</excludeTransitive> 
                    <stripVersion>true</stripVersion>
                    <outputDirectory>./lib</outputDirectory>
                </configuration>
                 
            </plugin>

附件:打包下载



参考博文:https://www.cnblogs.com/cliyun/p/5765875.html



猜你喜欢

转载自blog.csdn.net/u011561335/article/details/80322960