天天看點

eclipse中Server Locations選項

這幾天在開發的過程,使用

mvn tomcat7:redeploy

指令打包部署到伺服器上是,發現有報記憶體洩漏的日志。于是想在本地測試一下,看是哪裡沒有釋放好記憶體。日志如下:

registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
21-Jul-2018 09:54:55.965 WARNING [http-nio-52000-exec-31] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [iicc_inf] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:64)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)
21-Jul-2018 09:54:55.966 WARNING [http-nio-52000-exec-31] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [iicc_inf] appears to have started a thread named [Thread-17] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.net.SocketInputStream.socketRead0(Native Method)
 java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
 java.net.SocketInputStream.read(SocketInputStream.java:171)
 java.net.SocketInputStream.read(SocketInputStream.java:141)
 java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
 java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
 java.io.BufferedInputStream.read(BufferedInputStream.java:345)
 com.sun.jndi.ldap.Connection.run(Connection.java:860)
 java.lang.Thread.run(Thread.java:748)
21-Jul-2018 09:54:56.015 INFO [http-nio-52000-exec-31] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive            

可能是因為是spring-boot項目的原因,是以我在tomcat中删除項目時,控制台上并沒有列印日志。是以我想把manager加上,這樣我可以在控制台上解除安裝項目,指令行一樣解除安裝的目的。這就需要修改Server Locations了,以下說明Server Locations幾項目設定。

Server Locations包括三個選項:

  • Use workspace metadata(dose not modify Tomcat installation) 使用workspace的工作空間,不影響本地Tomcat安裝配置
  • Use Tomcat installation (takes control of Tomcat installation)

    使用和控制本地安裝的Tomcat

  • Use custom location (dose not modify Tomcat installation)

    使用自定義的目錄,不影響本地Tomcat安裝配置

eclipse中Server Locations選項

我們平時使用的配置都是第一項,tomcat啟動的時候,war包和日志實際的路徑可以在

Open launch configuration

這裡找到:

eclipse中Server Locations選項
eclipse中Server Locations選項

我今天要使用的是第二項

Use Tomcat installation

,啟動後,可以在tomcat的目錄下看到

wtpwebapps

目錄(其中wtpwebapps目錄可以改為webapps,因不想影響裡邊的程式就沒改),并且在logs目錄下也能看到通路日志。

eclipse中Server Locations選項

然後在

%tomcat%/conf/tomcat-users.xml

增加使用者,再從

http://localhost:8080/manager/html

登入就可以部署和解除安裝war應用了。

繼續閱讀