初做MAVEN项目 pom.xml报错

遇到了一些问题:

1[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project example: 
Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed: 
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: 
Failed to collect dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.5 (): 
Failed to read artifact descriptor for org.apache.maven:maven-plugin-descriptor:jar:2.0.6: 

解决方案:



原来 Eclipse 里的 Maven 会去读 User Home 里的 Maven 配置文件 settings.xml,预设是没有这个文档的,所以会使用默认的位置 User Home/.m2/repository。
只要在上图修改 settings.xml 到想要的位置,或者去修改 User Home/.m2/settings.xml。


这里我选择了从maven 官网下载下来的包中的配置文件



settings.xml 配置文件里面有个 localRepository  标签,更改你想要的地址就可以了。


2Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin

解决方案:

1.) add dependency to pom.xml

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
</dependency>

2.) run mvn install from Eclipse or from command line

3.) refresh the project in eclipse (F5)

4.) run Maven > Update Project Configuration... on project (right click)

3Failure to transfer org.sonatype.forge:forge-parent:pom:10 from http://repo.maven.apache.org/
 maven2 was cached in the local repository, resolution will not be reattempted until the update interval 
 of central has elapsed or updates are forced. Original error: Could not transfer artifact 
 org.sonatype.forge:forge-parent:pom:10 from/to central (http://repo.maven.apache.org/maven2): 
 connection timed out to http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/10/

 forge-parent-10.pom

解决方案:

修改dependencies

学习文档:

http://www.cnblogs.com/sschen/p/3664479.html

http://stackoverflow.com/questions/8834806/m2eclipse-error

### 回答1: 您好,可能出现pom.xml报错的原因有很多,需要具体分析。以下是一些常见的解决方法: 1. 检查pom.xml文件中的语法错误,比如标签未闭合、属性值未设置等等。 2. 检查maven的配置文件settings.xml是否正确配置,包括本地仓库路径、镜像源等。 3. 检查maven的版本是否正确,建议使用最新版本。 4. 检查eclipse中maven插件是否正确安装,可以尝试重新安装或更新插件。 5. 检查项目的依赖是否正确配置,可能存在依赖冲突或版本不兼容的情况。 希望以上方法能够帮助您解决问题。 ### 回答2: 在Eclipse创建maven项目时,构建时会自动生成一个pom.xml文件,这个文件是用来配置项目环境的,但是有时在生成pom.xml文件时会出现报错的情况。导致这种情况的主要原因有以下几种: 1. 网络问题:在生成pom.xml时,可能因为网络问题而导致下载maven的相关依赖库失败,从而出现报错的情况。 2. Eclipse环境问题:在某些情况下,Eclipse中的Maven插件可能会遇到一些意外状况,导致无法正确处理生成pom.xml文件的请求,从而出现报错的情况。 3. Jar包冲突:有时候,因为不同的模块之间依赖的jar包版本不同,从而导致生成pom.xml文件时出现报错的情况。 针对以上三种情况,可以采取以下方案解决问题: 1. 网络问题:可以设置代理服务器,也可以尝试手动下载maven的相关依赖库到本地仓库目录,再重新生成pom.xml文件。 2. Eclipse环境问题:可以先尝试关闭Eclipse,清空Eclipse的缓存目录,重新启动Eclipse,再尝试重新生成pom.xml文件。 3. Jar包冲突:可以检查不同模块依赖的jar包版本,看看是否有冲突,如果有冲突可以手动添加相应的依赖解决冲突。 总之,当出现pom.xml文件报错时,我们需要深入分析具体的错误信息,并找出具体的解决方案,在确保解决问题的同时,也可以对maven项目的管理和开发积累相关经验。 ### 回答3: 在eclipse中创建maven项目并生成pom.xml时,有时会遇到报错的情况。这些错误可能有不同的原因,例如: 1. 缺少maven插件:如果eclipse中没有安装maven插件或者安装的插件出了问题,可能会导致pom.xml报错。在这种情况下,可以尝试重新安装或更新maven插件以解决问题。 2. Maven版本问题:如果当前版本的maven项目pom.xml中定义的版本不一致,可能会导致pom.xml报错。这时,我们需要将maven升级或降级到与pom.xml文件中定义的版本一致。 3. 依赖访问权限问题:在pom.xml文件中定义的依赖库,如果没有正确的访问权限,可能会导致pom.xml报错。更正访问权限即可解决该问题。 4. 语法错误:pom.xml文件必须严格遵守XML语法格式,如果有语法问题,IDE就会提示报错。在这种情况下,需要仔细检查pom.xml文件中的语法格式是否正确。 5. 网络连接问题:在创建maven项目时,如果网络连接不畅,可能会导致maven库的引用失败,从而导致pom.xml报错。 这时需要确保网络连接是正常的,或者通过代理访问maven库解决问题。 以上是一些常见的出现pom.xml报错的情况,针对不同的问题,我们可以采取不同的方法来解决。但是总的来说,在创建maven项目时,我们需要严格遵守标准的语法,确保配置信息正确,与maven库的访问交流畅通无阻,才能创建出一个良好的maven项目
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值