[tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped
环境:一个tomcat ,一个工程配置了多数据源,在启动的时候报如下错误:
SEVERE: The web application [/qdp-resource-job] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/qdp-resource-job] 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. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] 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. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Create-827239851] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Destroy-827239851] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Create-913636676] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Destroy-913636676] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Create-789799328] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Destroy-789799328] but has failed to stop it. This is very likely to create a memory leak. Aug 14, 2017 3:23:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/qdp-resource-job] appears to have started a thread named [Druid-ConnectionPool-Create-927599675] but has failed to stop it. This is very likely to create a memory leak.
解决方法:在多数据源配置的时候,只配置一个在启动的时候进行初始化,其他的不动,如下:
<!-- 第一数据源 --> <bean name="dataSourceResource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialSize" value="${jdbc.initialSize}" /> <property name="minIdle" value="${jdbc.minIdle}" /> <property name="maxActive" value="${jdbc.maxActive}" /> <property name="maxWait" value="${jdbc.maxWait}" /> <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}" /> <property name="validationQuery" value="${jdbc.validationQuery}" /> <property name="testWhileIdle" value="${jdbc.testWhileIdle}" /> <property name="testOnBorrow" value="${jdbc.testOnBorrow}" /> <property name="testOnReturn" value="${jdbc.testOnReturn}" /> <property name="removeAbandoned" value="${jdbc.removeAbandoned}" /> <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}" /> <property name="filters" value="${jdbc.filters}" /> <property name="logAbandoned" value="true" /> <property name="proxyFilters"> <list> <ref bean="log-filter"/> </list> </property> </bean> <!-- 第二数据源 --> <bean name="dataSourceCustomer" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${customer.url}" /> <property name="username" value="${customer.username}" /> <property name="password" value="${customer.password}" /> </bean> <!-- 第三数据源 --> <bean name="dataSourceBuilding" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${building.url}" /> <property name="username" value="${building.username}" /> <property name="password" value="${building.password}" /> </bean>
第二和第三数据源只保留最基础的url 、username、password 三个配置即可!
分类:
Java
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决