- ConnectionFactoryConfig
@Bean
public ConnectionFactory connectionFactory(@Autowired MyR2dbcProperties r2dbcProperties) {
...
return connectionFactory;
}
- application.yml
behappy:
r2dbc:
host: localhost
username: root
password: root
port: 3306
database: bin-springreactive
pool:
name: r2dbc_pool_product
validation-depth: local
server:
port: 8080
spring:
application:
name: @project.artifactId@
# main:
# allow-bean-definition-overriding: true
↓
Description:
The bean 'connectionFactory', defined in class path resource [org/xiaowu/behappy/common/r2dbc/config/R2dbcEntityTemplateConfigure.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$Pool.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I have to configure to allow java bean overrides(allow-bean-definition-overriding: true) ,is that right?
Comment From: snicoll
@a943915349 it looks like your custom configuration is part of an auto-configuration of some sort. If you want your customization to run, it should be ordered so that it runs before R2dbcAutoConfiguration
. If you run after without a condition, you'll effectively override the bean, which is what this exception is warning you. If that code isn't part of an auto-configuration, please share a small sample that reproduces the problem (no code in text but a zip of a project or a link to a GitHub repo so that we can run it ourselves).
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: wang-xiaowu
@a943915349 it looks like your custom configuration is part of an auto-configuration of some sort. If you want your customization to run, it should be ordered so that it runs before
R2dbcAutoConfiguration
. If you run after without a condition, you'll effectively override the bean, which is what this exception is warning you. If that code isn't part of an auto-configuration, please share a small sample that reproduces the problem (no code in text but a zip of a project or a link to a GitHub repo so that we can run it ourselves).
ok, i'll try ,thank u so much