ZPY博客

Springboot启动报错’javax.management.MBeanServer’ that could not be found.

springboot启动报错

 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method endpointObjectNameFactory in org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration required a bean of type 'javax.management.MBeanServer' that could not be found.

Action:

Consider defining a bean of type 'javax.management.MBeanServer' in your configuration.

网上试了很多方法都不能解决问题,比如加上配置:spring.jmx.enabled=true,比如加上配置:management.endpoints.jmx.exposure.exclude=*

而且很奇怪的一点是我明明配置的是spring.jmx.enabled=false,我看了JmxEndpointAutoConfiguration这个类生效的条件是spring.jmx.enabled=true,不知道为啥会生效?

最后试了很多方法,用以下方法解决:

在Springboot启动类上排除掉JmxEndpointAutoConfiguration即可。

exclude = JmxEndpointAutoConfiguration.class