Target runtime Apache Tomcat v6.0 is not defined.错误解决方法

原文:http://blog.csdn.net/xw13106209/article/details/5910358

Eclipse导入工程后工程上显示一个小红叉,但工程里没有文件错误,也没有语法错误,百思不得其解啊,后来在网上找了一些资料说是项目引用的类库路径有问题。【项目】->【右键】->【build path】->【configure build path】->【libraries】,查看一下引用的类库路径。网上都说是因为这里引用错误引起的,但是我在项目导入的时候做的第一件事情就是修改这里的library,因此不是这个原因。

在problems中显示错误是:Target runtime Apache Tomcat 6.0 is not defined. 在网上查了一下终于找到解决方法。方法是:在工程目录下的.settings文件夹里,打开org.eclipse.wst.common.project.facet.core.xml文件,其内容是:

<?xmlversion="1.0"encoding="UTF-8"?> 
<
faceted-project
<
runtimename="Apache Tomcat v6.0"/> 
<
fixedfacet="jst.web"/> 
<
fixedfacet="jst.java"/> 
<
installedfacet="jst.java"version="6.0"/> 
<
installedfacet="jst.web"version="2.5"/> 
<
installedfacet="wst.jsdt.web"version="1.0"/> 
</
faceted-project>

将其修改为:

<span style="color: teal;"><?</span><span style="color: rgb(63, 127, 127);">xml </span><span style="color: rgb(127, 0, 127);">version</span>=<span style="color: rgb(42, 0, 255);">"1.0" </span><span style="color: rgb(127, 0, 127);">encoding</span>=<span style="color: rgb(42, 0, 255);">"UTF-8" </span><span style="color: teal;">?> 
<</span><span style="color: rgb(63, 127, 127);">faceted-project</span><span style="color: teal;">></span><span style="color: teal;">
</</span><span style="color: rgb(63, 127, 127);">faceted-project</span><span style="color: teal;">></span>
<span style="color: teal;"></span>

PS:进行上面的修改以后虽然没有错误了,但是想发布网站demo的时候发现没有【run as】->【run on server】这个选项了。这时候我们创建一个demo2的web project,然后查看.settings下的org.eclipse.wst.common.project.facet.core.xml,我们发现其内容是:

<span style="color: teal;"><?</span><span style="color: rgb(63, 127, 127);">xml </span><span style="color: rgb(127, 0, 127);">version</span>=<span style="color: rgb(42, 0, 255);">"1.0" </span><span style="color: rgb(127, 0, 127);">encoding</span>=<span style="color: rgb(42, 0, 255);">"UTF-8" </span><span style="color: teal;">?> 
 <</span><span style="color: rgb(63, 127, 127);">faceted-project</span><span style="color: teal;">>
  <</span><span style="color: rgb(63, 127, 127);">runtime </span><span style="color: rgb(127, 0, 127);">name</span>=<span style="color: rgb(42, 0, 255);">"Apache Tomcat v6.0.29" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">fixed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"jst.web" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">fixed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"java" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">fixed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"wst.jsdt.web" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">installed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"java" </span><span style="color: rgb(127, 0, 127);">version</span>=<span style="color: rgb(42, 0, 255);">"1.6" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">installed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"jst.web" </span><span style="color: rgb(127, 0, 127);">version</span>=<span style="color: rgb(42, 0, 255);">"2.5" </span><span style="color: teal;">/> 
  <</span><span style="color: rgb(63, 127, 127);">installed </span><span style="color: rgb(127, 0, 127);">facet</span>=<span style="color: rgb(42, 0, 255);">"wst.jsdt.web" </span><span style="color: rgb(127, 0, 127);">version</span>=<span style="color: rgb(42, 0, 255);">"1.0" </span><span style="color: teal;">/> 
  </</span><span style="color: rgb(63, 127, 127);">faceted-project</span><span style="color: teal;">></span>

那么我们只需要将该代码拷贝到网站demo下的.settings目录下,将原来的org.eclipse.wst.common.project.facet.core.xml覆盖即可。覆盖以后我们在Eclipse就能够使用【run as】->【run on server】来发布demo了。

最好的方法在11楼评论中:

最好用这样方法解决:项目--属性--targeted runtime,把原项目的tomcat去掉勾选...

重新选择tomcat 服务器版本,问题解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值