maven 离线编译 最小化仓库 坑 记录
打包了最小化的本地仓库到服务器进行离线编译,提示异常:
Some problems were encountered while processing the PoMsERROR[ERROR]Non-resolvable parent PoM for com.qxnw.scyc:scyc-parent:$irevision): Can[FATAL]not access maven-central (... offline mode and the artifact org.springframework.boot:spring-boot-starter-parent:pom:2.7.18 has not been downloaded frombefore. and 'parent.relativePath1tpoints at wrong local PoM @ line 8, column13
确认了离线库里有:
spring-boot
spring-boot-autoconfigure
spring-boot-dependencies
spring-boot-starter-parent
而且对应2.7.18版本也是对的。
解决问题:
指向的离线库“不是完整 Maven 本地仓库格式”
离线库目录里有:
- _remote.repositories
这个文件是 Maven/仓库管理工具用来记录“这个 artifact 是从哪个远程仓库来的”。
如果这个文件里记录的仓库 ID/URL 跟你当前的 settings/mirror 不一致 ,或者它标记了“不可用”,Maven 有时会认为该 artifact 不可用,从而仍然尝试走远程校验,离线模式下就报你这种错。
解决办法最稳的是: 不要让这类元文件影响判定 。
可以(仅针对离线库)删掉这些元文件后再试一次离线编译:
find /home/greatwall/qxnw/buildenv/scyc_all_m2 -name "_remote.repositories" -delete
find /home/greatwall/qxnw/buildenv/scyc_all_m2 -name "*.lastUpdated" -delete
移除后确实成功了:
~/maven-3.6.3/bin/mvn \
-Dmaven.repo.local=~/scyc_all_m2 \
-pl admin/admin-web -am \
-o package -DskipTests

浙公网安备 33010602011771号