Skip to content

Bean definitions in DataSourceConfiguration's inner classes override each other when multiple pools are on the classpath #13737

@wilkinsona

Description

@wilkinsona

There are no missing bean conditions on the pool-specific inner classes of DataSourceConfiguration so they can override each other when multiple pools are available. This can be seen by running org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests.testDataSourceHasEmbeddedDefault(). The overrides appear in the logs:

2018-07-09 17:31:19.975  INFO   --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@52bf72b5: startup date [Mon Jul 09 17:31:19 BST 2018]; root of context hierarchy
2018-07-09 17:31:20.178  INFO   --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Dbcp2; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Dbcp2] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat]
2018-07-09 17:31:20.179  INFO   --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari]
2018-07-09 17:31:20.314  INFO   --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-09 17:31:20.777  INFO   --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@52bf72b5: startup date [Mon Jul 09 17:31:19 BST 2018]; root of context hierarchy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions