Eclipse创建maven工程多个pom.xml总是出现pom.xml报错怎么办

用户名:secondriver
文章数:227
评论数:205
访问量:331034
注册日期:
阅读量:1297
阅读量:3317
阅读量:448892
阅读量:1133673
51CTO推荐博文
& & 使用Maven对项目进行管理的时候,多模块的继承和聚合是必不可少的,本文简要说明一下在eclipse IDE下创建多模块工程。& & 1.Maven多模块的聚合& & &&&& & 一个Maven工程下创建多个模块,然后用一个专门管理模块来将实际应用到的模块组织起来。& &2.Maven多模块的继承& & & & & & 子模块通过继承父模块,来获的父模块中的pom.xml配置信息。& &3.Maven多模块的继承+聚合& & & &&& & & 上图是将1和2组合起来,可以将父模块作为聚合模块和父模块,这样父模块就可以聚合(组织)其子模块,子模块可以继承父模块。& &4.聚合和继承的关系& & & &区别&:对于聚合模块来说,它知道有哪些被聚合的模块,但被聚合模块相互独立。对于继承关系的父POM来说,它不知道有哪些子模块继承它,但那些子模块都必须知道自己的父POM。& & &共同点&:聚合&POM与继承关系中的父POM的packaging都是pom。聚合模块与继承关系中的父模块除了POM之外都没有实际的内容。& && 5.使用Eclipse来搭建一个集成聚合和继承的工程& 5.1创建一个Maven工程,其作为聚合模块& & &&groupId&secondriver&/groupId&
&artifactId&code-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&packaging&pom&/packaging&
&name&code-parent&/name&
&url&http://maven.apache.org&/url&& 5.2创建JavaSE的Maven模块(code-utils,图中为code-utilss),并选择上面code-parent工程作为父工程. &&&&& 5.3同上,创建JavaWeb的Maven模块(code-web),并选择上面的code-parent工程作为符工程。& 5.4 Eclipse中的目录结构图&& & 途中有三个工程,准确的说code-parent是maven工程,code-utils,code-web是code-parent工程下的两个模块;code-parent对其进行了聚合,code-utils,code-web继承了code-parent.& && & 本地文件系统的目录结构:& &&& & code-parent下的pom文件即为父pom.xml,code-utils和code-web下的pom.xml继承该pom.xml.& &&&5.5 code-parent的pom.xml& &&&project&xmlns="http://maven.apache.org/POM/4.0.0"&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0&http://maven.apache.org/xsd/maven-4.0.0.xsd"&
&modelVersion&4.0.0&/modelVersion&
&groupId&secondriver&/groupId&
&artifactId&code-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&packaging&pom&/packaging&
&name&code-parent&/name&
&url&http://maven.apache.org&/url&
&module&code-utils&/module&
&module&code-web&/module&
&/modules&
&properties&
&project.build.sourceEncoding&UTF-8&/project.build.sourceEncoding&
&project.reporting.outputEncoding&UTF-8&/project.reporting.outputEncoding&
&junit.version&4.10&/junit.version&
&/properties&
&description&
这是父模块,对子模块进行了集成,子模块对该模块进行了继承。主要作用是对公共配置的统一管理
&/description&
&dependencies&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&version&${junit.version}&/version&
&scope&test&/scope&
&/dependency&
&/dependencies&
&dependencyManagement&
&dependencies&&/dependencies&
&/dependencyManagement&
&/project&& & 配置中packaging的值是pom,说明code-parent是一个聚合模块或者父模块,这里其属于两者。modules下配置了两个模块分别就是code-utils和code-web.5.6code-utils和code-web的pom.xmlcode-parent/code-utils/pom.xml& &&project&xmlns="http://maven.apache.org/POM/4.0.0"&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0&http://maven.apache.org/xsd/maven-4.0.0.xsd"&
&modelVersion&4.0.0&/modelVersion&
&groupId&secondriver&/groupId&
&artifactId&code-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&artifactId&code-utils&/artifactId&
&name&code-utils&/name&
&/project&& & & 配置中默认的packaging的值为jar。code-parent/code-web/pom.xml&?xml&version="1.0"?&
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0&http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&
&modelVersion&4.0.0&/modelVersion&
&groupId&secondriver&/groupId&
&artifactId&code-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&artifactId&code-web&/artifactId&
&packaging&war&/packaging&
&name&code-web&Maven&Webapp&/name&
&url&http://maven.apache.org&/url&
&finalName&code-web&/finalName&
&/project&& 至此通过Eclipse创建多模块的Maven工程已完成。至于pom.xml如何配置,就另当别论了,关于maven的pom.xml配置更多信息参见: 本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)eclipse创建maven工程时报错使用的是官方的Eclipse中自带的m2e插件,创建maven项目时就弹出个错误在pom.xml文件那会显示个红X,提示如下:Multipleannotation
eclipse创建maven工程时报错
使用的是官方的Eclipse中自带的m2e插件,创建maven项目时就弹出个错误
在pom.xml文件那会显示个红X,提示如下:
Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-
- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6
or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-
project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6,
org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6,
org.apache.maven:maven-error-diagnostics:jar:2.0.6, org.apache.maven:maven-plugin-descriptor:jar:2.0.6, org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-
settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6, org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:
Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.6 from
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.apache.maven:maven-plugin-api:jar:2.0.6 from/to central
( The operation was cancelled. (org.apache.maven.plugins:maven-resources-plugin:2.6:resources:default-resources:process-resources)
org.apache.maven.plugin.PluginExecutionException: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-
plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6,
org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6,
org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-error-diagnostics:jar:2.0.6, org.apache.maven:maven-plugin-descriptor:jar:2.0.6,
org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6,
org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1: Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.6 from
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.apache.maven:maven-plugin-api:jar:2.0.6 from/to central ( The operation was cancelled. at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at
org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331) at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362) at
org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) at
org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360) at
org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52) at
org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137) at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172) at
org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1) at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:
115) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod
$1.call(MavenBuilder.java:105) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99) at org.eclipse.m2e.core.internal.builder.MavenBuilder
$BuildMethod.execute(MavenBuilder.java:86) at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200) at org.eclipse.core.internal.events.BuildManager
$2.run(BuildManager.java:734) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300) at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303) at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382) at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at
org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-
plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-
project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6,
请问如何解决?谢谢
本机安装的maven是3.2.2
eclipse是4.5
最后也不知道什么原因,重新下了eclipse就没有问题了
有可能是maven的版本太高了。eclipse哪个版本的。maven哪个版本的
解决方案二:
试下使用maven 更新下工程呢?
解决方案三:
解决方案四:
本机安装的maven是3.2.2
eclipse是4.5
【云栖快讯】数据库技术天团集体亮相,分享一线生产实践经验,告诉你踩过的坑、走过的路,都是老司机,靠谱!干货分享,不可错过!&&
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率
稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一
6款热门基础云产品6个月免费体验;2款产品1年体验;1款产品2年体验
开发者常用软件,超百款实用软件一站式提供温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
Multiple annotations found at this line:- Execution default-testResources of goal org.apache.maven.plugins:maven-resources-
plugin:2.4.3:testResources failed:
Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources- plugin:2.4.3:testResources:default-testResources:process-test-resources)- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(execution: default-compile, phase: compile)- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.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.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http:// repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin- api-2.0.6.pom- CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.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.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http:// repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin- api-2.0.6.pom- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources failed: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources- plugin:2.4.3:resources:default-resources:process-resources)- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin: 2.3.2:testCompile (execution: default-testCompile, phase: test-compile)错误信息出现在pom头的project标签,project标签内容是&project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&原因这是由于缺少maven-resources-plugin-2.4.3.jar文件。这个文件是在{user.home}\.m2\repository\org\apache\maven\plugins\maven-resources-plugin\下。{user.home}是maven的配置路径,一般是我的文档,是window-preferences-MyEclipse-Maven4MyEclipse-User Setting里面的Local Repository。而我的该文件夹中只有maven-resources-plugin-2.4.3.pom.lastUpdated, 没有&maven-resources-plugin-2.4.3.jar文件;&解决方案1、在项目的pom.xml文件中加入maven-resources-plugin配置&dependency&
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-resources-plugin&/artifactId&
&version&2.4.3&/version&
&/dependency&2、在项目邮件下运行mvn install&,如果执行正确应该会在{user.home}\.m2\repository\org\apache\maven\plugins\maven-resources-plugin\下看到maven-resources-plugin-2.4.3.jar文件3、刷新工程(右键工程选择刷新项)4、刷新maven配置,右键工程节点,选择Maven4MyEclipse-Update Project Configuration
阅读(14071)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案',
blogAbstract:'maven 报错, 错误信息如下:&Multiple annotations found at this line:- Execution default-testResources of goal org.apache.maven.plugins:maven-resources-
plugin:2.4.3:testResources failed:
Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apa',
blogTag:'maven,plugin',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:7,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}}

我要回帖

更多关于 pom.xml怎么创建 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信