I have an simple app with spring boot EKS with kubernetes JDK17 spring-boot-starter-parent 3.1.3 spring-cloud-dependencies spring-cloud-starter-kubernetes-fabric8-config spring-cloud-starter-bootstrap
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 2 of method configMapPropertyChangeEventWatcher in org.springframework.cloud.kubernetes.fabric8.config.reload.Fabric8ConfigReloadAutoConfiguration required a single bean,
but 2 were found:
- configDataConfigMapPropertySourceLocator: a programmatically registered singleton
- configMapPropertySourceLocator: defined by method 'configMapPropertySourceLocator'
in class path resource [org/springframework/cloud/kubernetes/fabric8/config/Fabric8BootstrapConfiguration.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
","context":"default"}
bootstrap.properties:
spring.cloud.bootstrap.enabled=true
spring.main.cloud-platform=KUBERNETES
spring.cloud.kubernetes.discovery.enabled=false
spring.cloud.kubernetes.config.enabled=true
spring.cloud.kubernetes.reload.enabled=true
spring.cloud.kubernetes.secrets.enabled=true
spring.cloud.kubernetes.reload.monitoring-secrets=true
application.properties
spring.application.name=demo
spring.main.allow-bean-definition-overriding=true
spring.cloud.bootstrap.enabled=true
spring.main.cloud-platform=KUBERNETES
Does anyone have any ideas about what I am missing ?
spring-cloud-kubernetes
contributor here.You are using both config data api and bootstrap, at the same time, so 2 beans are created, where one is expected.
What I mean by that is that you have:
spring.config.import:kubernetes
inapplication.properties
(this is called "config data api" and is a modern replacement of "bootstrap", see this for more details)At the same time, you have enabled bootstrap also: you either have
spring-cloud-starter-bootstrap
on the classpath or this is set:spring.cloud.bootstrap.enabled=true
.Since both of these are configured, each will create a
@Bean
, but we expect only one. So disable one of them.