Skip to content

BeanDefinitionOverrideException: Invalid bean definition with name 'clientFactory' defined in class path resource [com/google/cloud/spring/autoconfigure/secretmanager/GcpSecretManagerAutoConfiguration.class] #4117

@tompson

Description

@tompson

Describe the bug
After upgrading from Spring Cloud GCP 7.2.0 to 7.3.0, our application fails to start due to a BeanDefinitionOverrideException. It seems that both GcpSecretManagerAutoConfiguration and GcpParameterManagerAutoConfiguration attempt to register a bean with the same name clientFactory.

Error trace (excerpt):

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'clientFactory' defined in class path resource [com/google/cloud/spring/autoconfigure/secretmanager/GcpSecretManagerAutoConfiguration.class]: Cannot register bean definition [Root bean: class=null; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; fallback=false; factoryBeanName=com.google.cloud.spring.autoconfigure.secretmanager.GcpSecretManagerAutoConfiguration; factoryMethodName=clientFactory; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/google/cloud/spring/autoconfigure/secretmanager/GcpSecretManagerAutoConfiguration.class]] for bean 'clientFactory' since there is already [Root bean: class=null; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; fallback=false; factoryBeanName=com.google.cloud.spring.autoconfigure.parametermanager.GcpParameterManagerAutoConfiguration; factoryMethodName=clientFactory; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/google/cloud/spring/autoconfigure/parametermanager/GcpParameterManagerAutoConfiguration.class]] bound.

This issue did not occur in version 7.2.0, but appears consistently in 7.3.0.


Sample
A minimal demo project reproducing the issue is available here: troii/gcp-test-fail.
The error occurs immediately on application startup when using Spring Boot with spring-cloud-gcp-starter-secretmanager.


Expected behavior
Both auto-configurations should be able to coexist, or beans should be properly namespaced to avoid overriding.


Environment

  • Spring Boot version: 3.5.5
  • Spring Cloud GCP version: 7.3.0 (works in 7.2.0)
  • Java version: 21

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions