Skip to content

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

Closed

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

Activity

  1. added this to the milestone on Jul 9, 2018
  2. wilkinsona commented on Jul 9, 2018

    @wilkinsona
    MemberAuthor

    The logs about are from 2.1. The problem goes back to 1.5 where the logs are as follows:

    2018-07-09 17:33:57.605  INFO   --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@482cd91f: startup date [Mon Jul 09 17:33:57 BST 2018]; root of context hierarchy
    2018-07-09 17:33:57.800  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$Dbcp; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Dbcp]
    2018-07-09 17:33:57.804  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$Dbcp; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Dbcp] 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:33:57.804  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$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari] 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:33:57.959  INFO   --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2018-07-09 17:33:58.584  INFO   --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@482cd91f: startup date [Mon Jul 09 17:33:57 BST 2018]; root of context hierarchy
    
  3. modified the milestones: , 1.5.15 on Jul 10, 2018
  4. added a commit that references this issue on Jul 10, 2018
    73a08dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions