For XXFor XX

作为一个高手
我习惯了孤独

解决Tomcat部署多个Spring boot报javax.management.InstanceAlreadyExistsException异常

Tomcat部署多个Spring boot+druid项目,启动报错。看错误日志是注册MBean时报错!

报错日志:

2018-01-23 09:45:19.376 [localhost-startStop-1] ERROR org.springframework.boot.SpringApplication 771 reportFailure - Application startup failed org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [com.alibaba.druid.filter.stat.StatFilter@55257bed] with key 'statFilter'; nested exception is javax.management.InstanceAlreadyExistsException: com.alibaba.druid.filter.stat:name=statFilter,type=StatFilter
    at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:628) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
...
Caused by: javax.management.InstanceAlreadyExistsException: com.alibaba.druid.filter.stat:name=statFilter,type=StatFilter
...

报错原因:

同一个domain里面的MBean要求name唯一

解决办法:

在application.properties配置中添加spring.jmx.default-domain=spring1,非同名的domain名字即可

转载请注明出处:For XX » 解决Tomcat部署多个Spring boot报javax.management.InstanceAlreadyExistsException异常
标签:Spring boot 报错异常
分享到: 更多