BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar'. InstanceAlreadyExistsException

后端 未结 1 599
不知归路
不知归路 2020-12-21 08:42

I have 2 spring boot applications.

application_A dependsn_on application_B

Actually each of applications has main class marked as @SpringBootApplicatio

相关标签:
1条回答
  • 2020-12-21 09:18

    The SpringApplicationAdminJmxAutoConfiguration has the code like:

    String jmxName = this.environment.getProperty(JMX_NAME_PROPERTY,
                DEFAULT_JMX_NAME);
        if (this.mbeanExporters != null) { // Make sure to not register that MBean twice
            for (MBeanExporter mbeanExporter : this.mbeanExporters) {
                mbeanExporter.addExcludedBean(jmxName);
            }
        }
        return new SpringApplicationAdminMXBeanRegistrar(jmxName);
    

    Where we have those constants:

    /**
     * The property to use to customize the {@code ObjectName} of the application admin
     * mbean.
     */
    private static final String JMX_NAME_PROPERTY = "spring.application.admin.jmx-name";
    
    /**
     * The default {@code ObjectName} of the application admin mbean.
     */
    private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
    

    So, you should consider to make that jmx-name as unique for each application. I mean you need specify spring.application.admin.jmx-name configuration property.

    0 讨论(0)
提交回复
热议问题