Myeclipse的動態web項目轉爲eclipse的動態web項目報錯

在Myeclipse中重新定義了web服務了目錄的文件夾,而這些,都定義在.classpath文件下

刪除Myeclipse的javaee容器標籤,如下,這一句不改會報找不到的錯誤。

如下:

Description Resource Path Location Type
Classpath entry melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER will not be exported or published.
Runtime ClassNotFoundExceptions may result.
orderdinner P/orderdinner Classpath Dependency Validator Message
刪除下面這一句
刪除classpath文件裏面的
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>  
然後在eclipse中導入這個工程,可能會出現以下錯誤
Description Resource Path Location Type
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path addfood.jsp
/orderdinner/WebRoot/admin line 1 JSP Problem
servlet相關的類找不到

點擊項目名--右鍵-->Build Path-->Configure Build Path

選擇Library,點擊Add Library,選擇Server Runtime點擊Next,選擇你配置的服務器,比如說Tomcat點擊Finish,點擊OK

然後配置以下運行時要用到的服務器

最後映射關係可能會出現問題點擊Properties-->Project Facets

勾選Dynamic Web Module,右邊的運行時注意選上tomcat

點擊下邊的Futher configuration available

Content directory改成WebRoot點擊Apply點擊OK

配置成功!

對比以下Myeclipse和eclipse的.classpath文件吧

myeclipse的文件

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/standard.jar"/>
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>

eclipse的文件
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<span style="white-space:pre"> </span><classpathentry kind="src" path="src"/>
<span style="white-space:pre"> </span><classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
<span style="white-space:pre"> </span><classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-1.4.jar"/>
<span style="white-space:pre"> </span><classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl.jar"/>
<span style="white-space:pre"> </span><classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar"/>
<span style="white-space:pre"> </span><classpathentry kind="lib" path="WebRoot/WEB-INF/lib/standard.jar"/>
<span style="white-space:pre"> </span><classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<span style="white-space:pre"> </span><attributes>
<span style="white-space:pre"> </span><attribute name="owner.project.facets" value="jst.web;#system#"/>
<span style="white-space:pre"> </span></attributes>
<span style="white-space:pre"> </span></classpathentry>
<span style="white-space:pre"> </span><classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7">
<span style="white-space:pre"> </span><attributes>
<span style="white-space:pre"> </span><attribute name="owner.project.facets" value="java"/>
<span style="white-space:pre"> </span></attributes>
<span style="white-space:pre"> </span></classpathentry>
<span style="white-space:pre"> </span><classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<span style="white-space:pre"> </span><classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<span style="white-space:pre"> </span><classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>

此外,還有另一種改法,也是比較常見的,在eclipse下新建動態Web 項目,然後複製src下的文件到src目錄,複製WebRoot目錄下的文件WebContent目錄下

對應的.classpath文件爲


<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>


詳細請看:http://blog.csdn.net/gsls200808/article/details/40710357;



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