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

本文介绍如何使用Maven将所需的jar包下载到本地。首先创建pom.xml文件定义依赖,然后通过bat文件调用Maven插件命令完成下载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

时至今日,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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰夏之夜影

赠人玫瑰,手留余香

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值