Receiving the following error when using Spring Boot 3.0.2 and spring-boot-starter-data-couchbase:
The bean 'transactionInterceptor', defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/example/demo/CouchbaseConfig.class] and overriding is disabled.
To recreate:
- go to start.spring.io and create a new Spring Boot 3.0.2 project with the couchbase starter dependency
- Create a configuration class extending
AbstractCouchbaseConfigurationjava @Configuration public CouchbaseConfig extends AbstractCouchbaseConfiguration { // override required methods } - Try and start the application
./gradlew bootRun
Is there something I'm missing with Spring Boot 3.0.2 and Couchbase starter?
https://github.com/spring-projects/spring-data-couchbase/blob/main/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java#L377-L388
https://github.com/spring-projects/spring-framework/blob/main/spring-tx/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java#L65-L74
Comment From: wilkinsona
Thanks for the report. This should be addressed in Spring Data Couchbase so that it does not define a bean whose name clashes with a bean defined by Spring Framework. They should perhaps be using a bean post-processor to customize the interceptor that Framework already defines. Please open a Spring Data Couchbase issue.
Comment From: mikereiche
@wilkinsona - if I used a different name for the bean, how would I get transactionAdvisor() in ProxyTransactionManagementConfiguration to use that bean?
Comment From: wilkinsona
I don't think you should rename your bean. Instead, I think you should remove your definition of the transactionAdvisor been and replace it with some customization of the bean that Framework defines. That could perhaps be done with a bean post-processor as suggested above. If that's not possible, I would ask the Framework team for some guidance. An alternative could be to use a bean factory post processor to change the definition but that's in danger of becoming a bit of a hack and should be something of a last resort.
Comment From: mikereiche
I think you should remove your definition of the transactionAdvisor been and replace it with some customization of the bean that Framework defines.
transactionAdvisor is a bean that the Framework defines. I'm customizing it by extending the class. The required customization is smack-dab in the middle of the processing. It's not in the post processing.
I did ask for guidance on this issue - I received no response. I will try again.
Comment From: wilkinsona
I've added a comment to the SDC issue that will hopefully make what I am suggesting more clear.