一个tomcat部署多个项目使用durid连接池报错
服务器windows server
tomcat7免安装板
问题:
在服务器上安装了一个tomcat7,需要在这个tomcat中部署3个项目,这三个项目都使用的是durid连接池,项目解压war包的时候就报错了。
ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager] - unregister mbean error
javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat
解决方案:
如果是通过windows服务启动的话,需要在tomcat的bin文件夹下找到tomcat7w.exe。找到java选项,在里面增加配置:
-Ddruid.registerToSysProperty=true。
项目能够正常启动。
注意:一般linux下通过shell脚本启动的话,需要改sh文件,windows需要改bat文件,注册成windows服务的需要在tomcat7w.exe中修改。
改jvm也是如此。