Eclipse中使用Maven我遇到过的常见报错解决整理

本文针对Maven构建过程中出现的多种错误进行详细解析,并提供了解决方案,包括父POM未找到、依赖丢失等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.MyProjectX:MyProjectX-manager-web:0.0.1-SNAPSHOT (E:\prj\Tech_accumulation\study_demo\MyProjectX-mvnProject\MyProjectX-manager\MyProjectX-manager-web\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.MyProjectX:MyProjectX-manager:0.0.1-SNAPSHOT: Could not find artifact com.MyProjectX:MyProjectX-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ com.MyProjectX:MyProjectX-manager:0.0.1-SNAPSHOT, E:\prj\Tech_accumulation\study_demo\MyProjectX-mvnProject\MyProjectX-manager\pom.xml, line 4, column 10 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
原因:在子模块中找不到父模块的pom.xml及相关依赖。<parent>元素的属性:<relativePath>: 表示父模块POM的相对路径,在构建的时候,Maven会先根据relativePath检查父POM,如果找不到,再从本地仓库查找
解决:
配置relativePath
    <parent>
        <groupId>com.MyProjectX</groupId>
        <artifactId>prj-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../prj-parent/pom.xml</relativePath>   //relativePath的默认值: ../pom.xml
    </parent>

资料:Maven详解之聚合与继承 http://blog.youkuaiyun.com/wanghantong/article/details/36427411


***********************************************************************************************************************
[ERROR] Failed to execute goal on project MyProjectX-manager-web: Could not resolve dependencies for project com.MyProjectX:MyProjectX-manager-web:war:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.MyProjectX:MyProjectX-common:jar:0.0.1-SNAPSHOT (compile), commons-logging:commons-logging:jar:1.2 (compile), mysql:mysql-connector-java:jar:5.1.40 (compile), org.springframework:spring-aop:jar:4.3.10.RELEASE (compile), org.springframework:spring-aspects:jar:4.3.10.RELEASE (compile), org.springframework:spring-beans:jar:4.3.10.RELEASE (compile), org.springframework:spring-context:jar:4.3.10.RELEASE (compile), org.springframework:spring-core:jar:4.3.10.RELEASE (compile), org.springframework:spring-expression:jar:4.3.10.RELEASE (compile), org.springframework:spring-instrument:jar:4.3.10.RELEASE (compile), org.springframework:spring-jdbc:jar:4.3.10.RELEASE (compile), org.springframework:spring-orm:jar:4.3.10.RELEASE (compile), org.springframework:spring-test:jar:4.3.10.RELEASE (compile), org.springframework:spring-web:jar:4.3.10.RELEASE (compile), org.springframework:spring-webmvc:jar:4.3.10.RELEASE (compile), org.mybatis:mybatis:jar:3.4.1 (compile), com.alibaba:druid:jar:1.0.29 (compile), javax.servlet:jstl:jar:1.2 (compile), taglibs:standard:jar:1.1.1 (compile), junit:junit:jar:3.8.1 (test), javax.servlet:javax.servlet-api:jar:3.1.0 (provided)]: Failed to read artifact descriptor for 
原因:依赖的jar或是工程找不到。
解决:在Maven的setting.xml中增加maven远程仓库镜像。http://www.cnblogs.com/hadoop2015/p/5717159.html    ---Failed to read artifact descriptor--maven问题总结(能力工场)


********************************************************************************************************
com.MyProjectX:MyProjectX-common:jar:0.0.1-SNAPSHOT: Could not find artifact com.MyProjectX:MyProjectX-parent:pom:0.0.1-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Could not find artifact com.MyProjectX:MyProjectX-parent:pom:0.0.1-SNAPSHOT -> [Help 1]
原因:依赖了MyProjectX:MyProjectX-parent工程。
解决: 将MyProjectX-parent 执行build install



********************************************************************************************************
 Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Initialization of bean failed; nested exception is java.lang.UnsupportedClassVersionError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException : Unsupported major.minor version 51.0
 (1)没有引入aspectjweaver有关的jar包  http://blog.youkuaiyun.com/you23hai45/article/details/56292396
    引入之后没有报错了。
    <!-- https://mvnrepository.com/artifact/aspectj/aspectjweaver -->
    <dependency>
        <groupId>aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.5.3</version>
    </dependency>


***********************************************************************************
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MyProjectX-manager-web: Failed to retrieve remote metadata com.MyProjectX:MyProjectX-manager-web:0.0.1-SNAPSHOT/maven-metadata.xml: 
Could not transfer metadata com.MyProjectX:MyProjectX-manager-web:0.0.1-SNAPSHOT/maven-metadata.xml from/to user-snapshot 

(http://localhost:8081/nexus/content/repositories/user-snapshot/): Connection refused: no further information to http://localhost:8081/nexus/content/repositories/user-snapshot/com/MyProjectX/MyProjectX-manager-web/0.0.1-SNAPSHOT/maven-metadata.xml -> [Help 1]
[ERROR] 
原因:maven向tomcat中deploy时,需要tomcat先运行起来。
解决:先运行tomcat,再deploy.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值