Maven管理项目,本地仓库有对应的jar包,但还是报找不到

业务场景

settings.xml种配置了私服,但是有些依赖私服上没有,通过同事拷贝过来的。但是用maven打包时报红了。

错误提示

Idea Maven错误:was cached in the local repository, resolution will not be reattempted until the update

was cached in the local repository, resolution will not be reattempted until the update interval of io.spring.repo.maven.release has elapsed or updates are forced

This failure was cached in the local repository and resolution is not reattempted until the update interval of repo183 has elapsed or updates are forced

[ERROR] Failed to execute goal on project XXX: Could not resolve dependencies for project com.vixtel.project:boce-subscriber:jar:2.1.0-20230908: com.vixtel.vaf:vaf-nacos-config-precheck:jar:2.4.0-20230801 was not found in http://36.134.39.183:4000/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of repo183 has elapsed or updates are forced

分析过程

  1. 按照提示,查找本地repository中是否有缺失的jar,但jar都是有的,同事拷贝的都有jar文件
  2. 参考几篇文章:maven依赖报红。解决本地有jar包,idea无法加载
    _remote.repositories文件的作用
    使用Maven管理项目时,明明本地仓库有对应的jar包,但还是报找不到
    快速清理本地仓库的文件

解释:maven3.x版本从远程库下载依赖后,会生成对应的_remote.repositories文件,标示该资源的来源。如果你有这个文件_remote.repositories,那就不会访问本地了,会去远程上找。必须远程上有才行,否则就会报错。

而我们的私服是没有依赖的,直接拷贝到的本地。

解决办法

删除对应仓库中的_remote.repositories文件

如果多可以使用快速清理本地仓库的文件

  • 15
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可能是你的本地 Maven 仓库出了问题,可以尝试以下几种解决方案: 1. 清理本地 Maven 仓库:在命令行中输入 `mvn clean install -U` 命令清理本地 Maven 仓库。 2. 检查 pom.xml 文件中的依赖是否正确:确保依赖的版本号和名称都正确,不要漏掉任何一个依赖。 3. 检查本地 Maven 仓库路径是否正确:在 Maven 的配置文件 settings.xml 中检查本地仓库路径是否正确。 4. 尝试删除本地 Maven 仓库中的对应包,然后重新构建项目。 如果以上方法都无法解决问题,可以尝试将该包手动添加到本地 Maven 仓库中。具体方法为: 1. 下载该包并解压。 2. 在命令行中进入该包所在的目录。 3. 执行以下命令将该包安装到本地 Maven 仓库中: ``` mvn install:install-file -DgroupId=<group-id> \ -DartifactId=<artifact-id> \ -Dversion=<version> \ -Dfile=<path-to-file> \ -Dpackaging=<packaging> \ -DgeneratePom=true ``` 其中,`<group-id>`、`<artifact-id>`、`<version>`、`<path-to-file>` 和 `<packaging>` 分别替换成对应的值。 例如,如果你要安装的包的坐标为 `com.example:example:1.0`,该包的文件路径为 `/path/to/example.jar`,类型为 `jar`,则上述命令应该改为: ``` mvn install:install-file -DgroupId=com.example \ -DartifactId=example \ -Dversion=1.0 \ -Dfile=/path/to/example.jar \ -Dpackaging=jar \ -DgeneratePom=true ``` 执行完以上命令后,该包就会被安装到本地 Maven 仓库中。然后你可以重新构建项目,应该就能找到该包了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值