欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > Springboot启动报错’javax.management.MBeanServer’ that could not be found.

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

2025/2/25 0:17:20 来源:https://blog.csdn.net/oak_javaLearner/article/details/144062691  浏览:    关键词:Springboot启动报错’javax.management.MBeanServer’ that could not be found.

报错信息如下图:
在这里插入图片描述
解决办法:
1.在你的.yml文件或者.properties文件里加上如下配置:
properties:

management.endpoints.jmx.enabled=false

yml:

management:endpoints:jmx:enabled: false

2.如果以上方法行不通,在springboot启动类的@SpringBootApplication注解里加上如下配置:

exclude= {JmxEndpointAutoConfiguration.class})

顺便一说,'javax.management.MBeanServer‘这个类是默认生效,必须手动声明使其失效,如果是单体springboot项目在分布式项目里有这个问题的话,方法1大概率会失效,建议直接用方法2

如果以上方法都不能使其失效,那还有一种方法就是按照spring的要求,给他创建一个mBeanServer的实例,也能解决问题,具体方法就是在启动类里加上以下配置:

@Bean
public MBeanServer mBeanServer() {MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();return mBeanServer;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词