当前位置:   article > 正文

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

cannot access nexus in offline mode and the artifact

问题背景

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

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

其中-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]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

解决方案

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

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

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

参考

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/87041
推荐阅读
相关标签
  

闽ICP备14008679号