1. 程式人生 > >[無bug,不程式設計] two or more web modules defined in the configuration have the same context root(/專案名)。

[無bug,不程式設計] two or more web modules defined in the configuration have the same context root(/專案名)。

被Eclipse中的Tomcat報錯折磨得死去活來的我,終於決定留個文章以備未來自己重蹈覆轍的時候檢視。。

產生原因: 因為tomcat為專案建立伺服器的配置出現錯誤。

解決辦法:

    1.找到兩個檔案:

        工作路徑\Servers\Tomcat v7.0 Server at localhost-config\server.xml

        工作路徑\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml

    2.兩個檔案的結尾附近都有重複的程式碼,相信你對你自己的專案名一定很敏感= =

       <Context docBase="專案名
" path="
/專案名"reloadable="true" source="org.eclipse.jst.j2ee.server:專案名"/>    <Context docBase="專案名" path="/專案名"reloadable="true" source="org.eclipse.jst.j2ee.server:專案名"/>

    3.別客氣,這兩段都刪掉,刪掉!!

    4.接下來,就是見證奇蹟的時刻= =

最後的最後,聽聞有不用eclipse,但tomcat本身也出現這個問題的人,附上網上另一個解決方案,好不好用這種事。。這麼多bug都闖過來的人,不解釋。。

    將D:\Test\Servers\Tomcat v5.5 Server at localhost-config\server.xml當中新加入的錯誤Context刪除,同時將D:\Test\test\.settings\org.eclipse.wst.common.component當中的deploy-name和property name的鍵值改為新專案的名稱,重新加入tomcat的服務,問題解決。

    <Context docBase="專案名" path="/專案名"reloadable="true" source="org.eclipse.jst.j2ee.server:專案名
"/>
    <Context docBase="專案名" path="/專案名"reloadable="true" source="org.eclipse.jst.j2ee.server:專案名"/>