[SPRING] BeanCreationException : 'springApplicationAdminRegistrar'라는 이름의 빈을 만드는 동안 오류가 발생했습니다. InstanceAlreadyExistsException
SPRINGBeanCreationException : 'springApplicationAdminRegistrar'라는 이름의 빈을 만드는 동안 오류가 발생했습니다. InstanceAlreadyExistsException
저는 2 개의 스프링 부트 응용 프로그램을 가지고 있습니다.
application_A dependsn_on application_B
실제로 각 응용 프로그램에는 @SpringBootApplication으로 표시된 주 클래스가 있습니다.
application_B는 시작되었지만 application_A가 시작되지 않습니다.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication # JMX name of the application admin MBean.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at pack.Application.main(Application.java:36)
Caused by: javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication # JMX name of the application admin MBean.
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar.afterPropertiesSet(SpringApplicationAdminMXBeanRegistrar.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 15 common frames omitted
디버그에서 나는 spring이 시작하는 동안 org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration # springApplicationAdminRegistrar를 두 번 실행하여 실패하는 것을 봅니다.
나는 속성을 설정하려고 :
spring.application.admin.enabled=false
그러나 그것은 나를 돕지 않습니다.
이 예외는 어떻게 피할 수 있습니까?
나는 이것 하나를 찾았습니다 https://github.com/spring-projects/spring-boot/issues/6378 그러나 해결책은 없습니다
해결법
-
==============================
1.SpringApplicationAdminJmxAutoConfiguration에는 다음과 같은 코드가 있습니다.
SpringApplicationAdminJmxAutoConfiguration에는 다음과 같은 코드가 있습니다.
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);
우리가 상수를 가지고있는 곳 :
/** * 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";
따라서 jmx-name을 각 응용 프로그램마다 고유 한 것으로 간주해야합니다. spring.application.admin.jmx-name 구성 속성을 지정해야한다는 뜻입니다.
from https://stackoverflow.com/questions/48567562/beancreationexception-error-creating-bean-with-name-springapplicationadminregi by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 봄 데이터 JPA - 개체를 반환하는 가장 좋은 방법은? (0) | 2019.01.07 |
---|---|
[SPRING] @ Cacheable with Ehcache, 유효한 객체에 대해 null을 찾습니다. (0) | 2019.01.07 |
[SPRING] 런타임에서 메일 구성 변경 (0) | 2019.01.07 |
[SPRING] 배열에서 일치하는 요소를 봄 mongodb에서 검색하는 방법은 무엇입니까? (0) | 2019.01.07 |
[SPRING] 스트럿츠 인터셉터에 봄 콩을 주입하는 법 .. 가능하다. (0) | 2019.01.07 |