現象:Tomcat 啟動時專案載入兩次,ServletContextListener、Spring 容器、連接池全雙重初始化。
Eclipse Server 設定 Server Locations → "Use Tomcat installation" 會導致:
wtpwebapps/ 並寫入 server.xml ContextappBase="webapps" 自動掃描部署專案<!-- 刪除 server.xml 中對應專案的 Context 節點 -->
副作用:Eclipse Server 視圖 Web Modules 列表為空。
webroot/server.xml:<Host appBase="webroot">docBase="../webapps/myapp-web"(相對路徑)<Host name="localhost" appBase="webroot" ...>
<Context path="/myapp" docBase="../webapps/myapp-web" reloadable="true" />
</Host>
保持預設 "Use workspace metadata",Eclipse 完全接管部署,無衝突、無雙重加載。
啟動日誌中 Initializing Spring root WebApplicationContext 僅出現一次。