欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Maven error: Failed to execute goal on project : Could not resolve dependencies for project 解决办法

程序员文章站 2022-07-03 18:07:05
...

执行maven install的时候遇见下面的错误

Maven error: Failed to execute goal on project : Could not resolve dependencies for project

具体报错信息如下

Failed to execute goal on project ui: 
    Could not resolve dependencies for project <<package>>:ui:war:1.0: Failed to collect dependencies for [javax.servlet:servlet-api:jar:2.5 (provided), 
    org.springframework:spring-core:jar:3.0.5.RELEASE (compile), 
    org.springframework:spring-web:jar:3.0.5.RELEASE (compile), 
    cglib:cglib:jar:2.2 (compile), org.springframework:spring-aop:jar:3.0.5.RELEASE (compile), 
    org.springframework:spring-webmvc:jar:3.0.5.RELEASE (compile), org.springframework:spring-context:jar:3.0.5.RELEASE (compile), 
    org.freemarker:freemarker:jar:2.3.18 (compile), gr.imu.ntua.tweetinspire:services:jar:1.0 (compile), 
    org.cloudfoundry.samples:tomcat7-standalone:tar.gz:7.0.29 (compile), org.slf4j:slf4j-api:jar:1.6.1 (compile), 
    org.slf4j:slf4j-log4j12:jar:1.6.1 (compile), org.slf4j:jcl-over-slf4j:jar:1.6.1 (compile), 
    commons-logging:commons-logging:jar:1.1.1 (compile), junit:junit:jar:4.8.1 (test), 
    org.springframework:spring-test:jar:3.0.5.RELEASE (test), org.dbunit:dbunit:jar:2.4.8 (test)]: Failed to read artifact descriptor for org.cloudfoundry.samples:tomcat7-standalone:tar.gz:7.0.29: Could not transfer artifact org.cloudfoundry.samples:tomcat7-standalone:pom:7.0.29 from/to jets3t (http://maven.oschina.net/content/groups/public): Access denied to: http://maven.oschina.net/content/groups/public.pom, ReasonPhrase:Forbidden


 

报错信息显示Maven无法从默认的远程仓库地址http://maven.oschina.net/content/groups/public下载依赖包。所以要解决的就是把远程仓库地址换一下。推荐使用阿里云的远程仓库。

要更换默认远程仓库地址需要找到.m2文件夹下面的settings.xml文件。一般都是在C:\Users\Administrator\.m2下面。(开始我改的maven/conf目录下面的settings.xml文件但是没有用,所以需要改.m2文件夹下面的)找到之后打开,将原来默认远程仓库地址http://maven.oschina.net/content/groups/public改为阿里云mavaen仓库地址http://maven.aliyun.com/nexus/content/groups/public之后保存即可。如下图

Maven error: Failed to execute goal on project : Could not resolve dependencies for project 解决办法