在同一个tomcat下部署两个springboot的war包时会出现以下错误:
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [com.alibaba.druid.filter.stat.StatFilter@501c1218] with key 'statFilter'; nested exception is javax.management.InstanceAlreadyExistsException: com.alibaba.druid.filter.stat:name=statFilter,type=StatFilter
因为在springboot中:spring.jmx.default-domain 是默认打开的,两个war包MBean注册冲突。
有两种解决方案:
方案1:在application.yml配置文件中各自添加配置:
spring.jmx.enabled=false
方案2:在application.yml中各自配置:
spring.jmx.default-domain=project1
spring.jmx.default-domain=project2