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

5288人阅读
http://blog.csdn.net/maosijunzi/article/details/
eclipse indigo,
maven 3.2.1,
tomcat7.0.42
2:安装eclipse maven插件 m2eclipse
第一种方法:从网上下载m2eclipse,这个网上有很多下载的地方。然后放到eclipse安装目录的plugins下。
第二种方法:打开eclipse-&help-&install new software。在work with后输入:。如图:
3:下载maven和tomcat
上apache官网下载maven:。下载完成后解压即可。
上apache官网下载tomcat:。
4:eclipse配置maven
window-》prefrences-》maven-》user setting。如图
window-》prefrences-》maven-》installations。如图
5:配置tomcat和maven
进入tomcat_home/conf/tomcat_users.xml:修改如下:
进入maven_home/conf/settings.xml:修改如下:
6:eclipse创建maven web项目
这个简单,new-》other-》maven project-》next。这里注意groupid选org.apache.maven.archetypes&,artifactid 选maven-archetype-webapp,然后next,输入我们自己的groupid(com.test),artifactid(transition),然后finish,OK。如图所示:
7:修改pom.xml
8:运行maven项目
先进入tomcat目录启动tomcat,然后右键项目 run as-》run configrations:
Goals项输入:package tomcat:redeploy
Maven Runtime选择我们自己的maven。如图:
然后点Run,控制台显示如下:
这里省略很多控制台输出,出现BUILD SUCCESS 则说明部署成功,浏览器输入:。显示Hello
&注意:这样成功之后项目会直接打成war包,部署到tomcat下,每次build不需要重启tomcat。这样致命的缺点就是,不能调试。如果需要调试且在eclipse中启动tomcat的话。会发现右键项目没有run as server,有两种方法解决:
第一种:这时需要把项目转变成dynamic web module。右键项目-》properties-》project facets,然后右边选中dynamic web module。之后就会出现run as& server了.
第二种:右键项目,run/debug& as& configrations& 如上第8步骤的图。不过Goals中天上【tomcat:run】。然后run就OK了,注意这里不需要提前启动tomcat。
创建完成后pom文件报错
Description Resource Path Location Type&
Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-war-plugin:pom:2.1.1 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.plugins:maven-war-plugin:pom:2.1.1 from/to central (http://repo1.maven.org/maven2): ConnectException first-maven Unknown Maven Problem&
1个答案<div class="vote" id="vote_solution_应该是连不上http://repo1.maven.org/maven2这个仓库,在你的pom.xml文件加一下下面的配置试试看。&Xml代码&&&&&&&&&&&&&&&&&&&&&&&&&&false&&&&&&&&&&&&&&&&central&&&&&&&&Maven&Repository&Switchboard&&&&&&&&http://repo2.maven.org/maven2&&&&&&&&&&&&010Description Resource Path Location Type&Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-war-plugin:pom:2.1.1 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.plugins:maven-war-plugin:pom:2.1.1 from/to central (http://repo1.maven.org/maven2): ConnectException first-maven Unknown Maven Problem&日 15:18
<div class="vote" id="vote_solution_
应该是连不上http://repo1.maven.org/maven2这个仓库,在你的pom.xml文件加一下下面的配置试试看。&
&&&&&&&&false&&
&&&&&&central&&
&&&&&&Maven&Repository&Switchboard&&
&&&&&&http://repo2.maven.org/maven2&&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:21004次
排名:千里之外
转载:44篇
(1)(3)(3)(6)(7)(7)(18)(2)1104人阅读
Dynamic Web Modu
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:87182次
排名:千里之外
原创:163篇匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。18:30 提问
创建Maven项目
pom.xml文件报错
创建maven项目 pom.xml文件提示错误:
Failure to transfer org.apache.maven.surefire:surefire:pom:2.10 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.surefire:surefire:pom:2.10 from/to central ( java.net.ConnectException:
connection timed out to
在网上搜索后给出的解决方法是
打开maven的本地库...\repository\org\apache\maven\plugins\maven-surefire-plugin\2.10会发现:里面少只有一个maven-surefire-plugin-2.10.pom.lastUpdated,而没有maven-surefire-plugin-2.10.jar
解决方法:
1.删除maven-surefire-plugin-2.7.1.pom.lastUpdated文件
2.右键点击project -& Maven - Update Dependencies
但我的本地库有aven-surefire-plugin-2.10.jar以及相关文件 没有maven-surefire-plugin-2.10.pom.lastUpdated文件 怎么还报这样的错误 在网上搜索好长时间 一直没有解决
求大神指点!!
按赞数排序
估计是包的问题,要不删了自己的包从maven下一个最新的?
对于Windows操作系统,执行
cd %userprofile%.m2\repository
for /r %i in
(*.lastUpdated)
然后在项目名右击,选择maven-&update project,即可。
我去 没看见是2014年的 不过有这么高的访问量 应该能有很多人看见这个回答解决问题。对于原理我也不清楚为什么希望理解的大神帮我解释一下。

我要回帖

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

 

随机推荐