Неверное определение компонента с именем 'configServicePropertySource' - PullRequest
0 голосов
/ 04 ноября 2018

Я определил ConfigServicePropertySourceLocator bean как следующий

@Primary
@Bean
public ConfigServicePropertySourceLocator configServicePropertySource(
        ConfigClientProperties configClientProperties) {
    ConfigServicePropertySourceLocator sourceLocator = new ConfigServicePropertySourceLocator(
            configClientProperties);
    sourceLocator.setRestTemplate(clientOnlyRestTemplate());
    return sourceLocator;
}

но я получаю следующее исключение (это то, как оно печатается в докере), хотя мой бин помечен как @Primary

WARN 1 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.support.BeanDefinitionOverrideException: 
Invalid bean definition with name 'configServicePropertySource' defined in de.ig.client.security.configuration.ConfigClientSecurityConfiguration: 
Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; 
dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=configClientSecurityConfiguration; 
factoryMethodName=configServicePropertySource; initMethodName=null; destroyMethodName=(inferred); 
defined in de.ig.client.security.configuration.ConfigClientSecurityConfiguration] for bean 'configServicePropertySource': 
There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; 
autowireCandidate=true; primary=false; factoryBeanName=configServiceBootstrapConfiguration; 
factoryMethodName=configServicePropertySource; initMethodName=null; destroyMethodName=(inferred); 
defined in org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration] bound.

1 Ответ

0 голосов
/ 04 ноября 2018

Решил, установив

spring.main.allow-bean-definition-overriding до true

Новое с загрузочной версии 2.1

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...