The web application [] 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
阿新 • • 發佈:2020-10-16
SSM整合小專案關閉時tomcat報錯:
The web application [] 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
原因似乎是資料庫的驅動無法釋放。
解決方法:
- pom.xml中的mysql驅動依賴去掉。
- 將mysql驅動包新增到tomcat安裝目錄下的lib資料夾中。
- 自定義監聽器:
public class DriverMangerListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { } public void contextDestroyed(ServletContextEvent sce) { Enumeration<Driver> enumeration = DriverManager.getDrivers(); while (enumeration.hasMoreElements()) { try { DriverManager.deregisterDriver(enumeration.nextElement()); } catch (SQLException e) { e.printStackTrace(); } } } }
- 將該監聽器在web.xml中配置:
<listener>
<listener-class>com.ssm.listener.DriverMangerListener</listener-class>
</listener>
- ok。