Target runtime Apache Tomcat v6.0 is not defined.錯誤解決方法

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了。


轉載來自:http://blog.csdn.net/xw13106209/article/details/5910358

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章