How to enable jmx for embedded tomcat in spring boot application

Viewed 4138

I am using embedded tomcat for springboot application but when i use jmx to get mbeans through jconsole i dont see any tomcat bean later i found that we have to enable tomcat bean by configuring it conf file but as i am using embedded tomcat how to enable jmx for embedded tomcat

2 Answers

Enable the tomcat MBean registry:

server.tomcat.mbeanregistry.enabled=true

Or, programmatically (Spring Boot 2)

@Configuration
public class TomcatConfiguration {
    @Bean
    public WebServerFactoryCustomizer<TomcatServletWebServerFactory> customizer(){
        return customizer -> {
            customizer.setDisableMBeanRegistry(false);
        }
}
Related