How to configure JMX with Spring Boot

前端 未结 2 1337
执笔经年
执笔经年 2021-02-06 02:26

I have created a Spring Integration application with Spring Boot. I would like to know how to configure JMX with Spring Boot. I believe by default JMX is configured when usin

相关标签:
2条回答
  • 2021-02-06 02:59

    It is quite late to add this; but in addition to the endpoints.jmx.domain I found it useful to change the spring.jmx.default-domain to someting unique per application

    This is with multiple instances of Spring Boot 1.4.1 apps running in Tomcat 7

    0 讨论(0)
  • 2021-02-06 03:02

    As you understand the Spring Integration JMX is enabled by default, if you just have spring-integration-jmx in the classpath. And, of course, if spring.jmx.enabled = true (default).

    You can't overrride that just declaring one more @EnableIntegrationMBeanExport, because it is based on @Import and you just can't override import classes because of (from ConfigurationClassParser):

    imports.addAll(sourceClass.getAnnotationAttributes(Import.class.getName(), "value"));
    

    If imported classes are already there, they aren't overridable.

    You have several choices to achieve your requirements:

    1. Disable default Spring Boot JMX - just addind to the application.properties spring.jmx.enabled = false and continue to use @EnableIntegrationMBeanExport

    2. Configure IntegrationMBeanExporter @Bean manually.

    3. Just configure your my.company.domain domain in the application.properties:

      spring.jmx.default_domain = my.company.domain
      
    0 讨论(0)
提交回复
热议问题