maven离线(offline)构建时无法找到本地依赖 Non-resolvable import POM: Cannot access nexus

问题背景

项目生产环境因为各种原因,不允许访问maven仓库,只能将本地下载完成的仓库打包上传到服务器上。maven构建命令如下:

mvn clean package -Pprod -Dmaven.test.skip=true -o

其中-o标识离线模式。同时也需要在maven的setting.xml文件中指定离线模式:

在这里插入图片描述

问题现象

报错信息如下:

在这里插入图片描述

[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact com.fasterxml.jackson:jackson-bom:pom:2.10.0 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 629, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact io.micrometer:micrometer-bom:pom:1.3.1 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 1027, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact io.netty:netty-bom:pom:4.1.43.Final has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 1034, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact io.projectreactor:reactor-bom:pom:Dysprosium-SR1 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 1046, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact io.rsocket:rsocket-bom:pom:1.0.0-RC5 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 1108, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.apache.logging.log4j:log4j-bom:pom:2.12.1 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 1797, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.eclipse.jetty:jetty-bom:pom:9.4.22.v20191022 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 2105, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.glassfish.jersey:jersey-bom:pom:2.29.1 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 2239, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.jetbrains.kotlin:kotlin-bom:pom:1.3.50 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 2581, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.jetbrains.kotlinx:kotlinx-coroutines-bom:pom:1.3.2 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 2588, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Cannot access nexus (http://maven.xxxyyy.com/nexus/content/groups/public/) in offline mode and the artifact org.junit:junit-bom:pom:5.5.2 has not been downloaded from it before. @ org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE, /mvnrepo/org/springframework/boot/spring-boot-dependencies/2.2.1.RELEASE/spring-boot-dependencies-2.2.1.RELEASE.pom, line 2615, column 19 -> [Help 2]

解决方案

在本地仓库根目录下,执行以下命令:

find . -name "_remote.repositories" | xargs rm 

该命令会删除所有子目录下_remote.repositories文件。

参考

https://stackoverflow.com/questions/16866978/maven-cant-find-my-local-artifacts/16870552

  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值