一个两年前的老项目,近期客户需要使用,时间跨度比较长,操作系统都重新安装了,项目环境都需要重新配置搭建,当基础的组件都安装好后,需要用maven命令进行重新编译一下,项目是采用maven管理多个子项目模块的,子项目之间需要互相引用,结果跑打包命令时错误不断,刚开始是出现如下错误:
[ERROR] Failed to execute goal on project nky-admin: Could not resolve dependencies for project com.yurongbj:nky-admin:jar:1.0.0: Failed to collect dependencies at com.yurongbj:yurongbj-framework:jar:4.6.1: Failed to read artifact descriptor for com.yurongbj:yurongbj-framework:jar:4.6.1: Could not transfer artifact com.yurongbj:yurongbj-framework:pom:4.6.1 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [public (http://maven.aliyun.com/nexus/content/groups/public/, default, releases+snapshots)] -> [Help 1]
这个错误是由于maven没有配置阿里云的maven镜像引起的,需要在maven安装目录下找到setting.xml配置文件,在文件中
mirrors节点下添加如下镜像配置节点
<mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
重新再跑maven的打包命令,结果又出现如下错误:
[ERROR] Failed to execute goal on project nky-admin: Could not resolve dependencies for project com.yurongbj:nky-admin:jar:1.0.0: The following artifacts could not be resolved: com.yurongbj:yurongbj-framework:jar:4.6.1, com.yurongbj:yurongbj-quartz:jar:4.6.1, com.yurongbj:yurongbj-generator:jar:4.6.1: com.yurongbj:yurongbj-framework:jar:4.6.1 was not found in http://maven.aliyun.com/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of public has elapsed or updates are forced -> [Help 1]
这个问题是由于maven的本地仓库没有配置好,继续打开setting.xml配置文件,在settings节点下添加如下本地仓库配置即可:
<localRepository>D:\mavenRepository</localRepository> <!--本地仓库路径视自己本地存放目录而定-->
以上两个配置项都做好后,重新跑maven的打包命令就能正常了。如果依然有错误,就按照提示将子项目模块一个一个进行编译,先运行maven的clean命令,然后执行maven的install命令,子项目没报错后,再执行总项目下的maven打包命令。
2013-2024 LifeAdd生活方式 www.lifeadd.cn 版权所有 | 御融(北京)科技有限公司 All Rights
Reserved
增值电信业务经营许可证:京B2-20200664 | 京ICP备14004911号-7