Maven相关知识点记录

1. 本地maven仓库有jar包,但是项目却从私服读取依赖

背景:将项目迁移到离线的电脑上进行开发,在读取依赖时,明明本地maven库有对应的jar包,但是项目却从私服读取,显示下载失败

报错信息:

[INFO] Scanning for projects...

[INFO]

[INFO] -------------------------< org.example:utils >--------------------------

[INFO] Building utils 1.0-SNAPSHOT

[INFO] --------------------------------[ jar ]---------------------------------

Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/tukaani/xz/1.9/xz-1.9.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  0.598 s

[INFO] Finished at: 2023-12-15T14:39:02+08:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal on project utils: Could not resolve dependencies for project org.example:utils:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.tukaani:xz:jar:1.9: Failed to read artifact descriptor for org.tukaani:xz:jar:1.9: Could not transfer artifact org.tukaani:xz:pom:1.9 from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/): maven.aliyun.com: Unknown host maven.aliyun.com -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] DependencyResolutionException - Apache Maven - Apache Software Foundation

检查过程如下:

1. 首先检查POM文件中的依赖配置是否正确,检查该依赖在本地库中是否已存在

<dependency>
    <groupId>
org.tukaani</groupId>
    <artifactId>
xz</artifactId>
    <version>
1.9</version>
</dependency>

2. 检查本地仓库的配置是否正确,即检查Maven的settings.xml文件中的localRepository元素,判断路径是否正确

<localRepository>E:\mvnwork</localRepository>

3. 修改对应依赖路径下的_remote.repositories文件

原本内容:

xz-1.9.jar>central=

xz-1.9.pom>central=

修改为:

xz-1.9.jar> =

xz-1.9.pom> =

然后重新加载依赖,成功加载。

或者可以直接将该文件删除。

  • 14
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值