1. 程式人生 > >The web application [ROOT] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed

The web application [ROOT] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed

        為了節省你的時間,請主要看紅色字型部分。

        前段時間開發專案一切正常,後面將專案拷貝了一份,執行在同一個tomcat上,發現執行時出現了警告資訊,專案就無法訪問了。

警告資訊:

23-Jul-2018 14:08:12.735 警告 [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
23-Jul-2018 14:08:12.735 警告 [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] 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.
23-Jul-2018 14:08:12.735 警告 [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] 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.


 

       上網查了很多資料,好多都說要重寫JBDC註冊的方法,也有說換tomcat版本,我都試了沒用。另外找了一個方法,就是將資料庫驅動包拷貝到tomcat的lib目錄中,我剛開始拷貝過去了,也沒有解決。

       最後看到有人說驅動包最好不要和專案一起打包,突然靈機一動,試著把專案中的資料庫驅動maven依賴註釋掉,專案就可以執行正常了,真的是坑啊!