Skip to content

Auto-configuration of Spring Integration's JDBC support does not use the auto-configured DataSource #14175

@garyrussell

Description

@garyrussell

With Boot 2.0.4:

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-integration</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.integration</groupId>
			<artifactId>spring-integration-jdbc</artifactId>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
@SpringBootApplication
public class Igh25431Application {

	public static void main(String[] args) {
		SpringApplication.run(Igh25431Application.class, args);
	}

	@Bean
	public JdbcMessageStore store(DataSource dataSource) {
		return new JdbcMessageStore(dataSource);
	}

}
spring.datasource.url=jdbc:mysql://localhost/integration
spring.datasource.username=root
#spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.integration.jdbc.initialize-schema=always

logging.level.root=debug
2018-08-22 14:12:42.704 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating shared instance of singleton bean 'store'
2018-08-22 14:12:42.704 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'store'
2018-08-22 14:12:42.704 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2018-08-22 14:12:42.704 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'igh25431Application'
2018-08-22 14:12:42.705 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating shared instance of singleton bean 'dataSource'
2018-08-22 14:12:42.705 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'dataSource'
...
2018-08-22 14:12:42.744 DEBUG 64743 --- [           main] com.zaxxer.hikari.HikariConfig           : Driver class com.mysql.jdbc.Driver found in Thread context class loader sun.misc.Launcher$AppClassLoader@764c12b6
...
2018-08-22 14:12:42.765 DEBUG 64743 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'dataSource'
   IntegrationAutoConfiguration.IntegrationJdbcConfiguration:
      Did not match:
         - @ConditionalOnSingleCandidate (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)
      Matched:
         - @ConditionalOnClass found required class 'org.springframework.integration.jdbc.store.JdbcMessageStore'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)

Clearly we have a DataSource but auto config doesn't find it for some reason.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions