It seems like I'm missing something: automatic injection of the data source works, but the injection of the DataSourceTransactionManager fails.
Dependencies:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.1.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> </dependencies>
the code:
@SpringBootApplication public class MainApplication { @Autowired private DataSource dataSource; // this fails @Autowired private DataSourceTransactionManager transactionManager; public static void main(String... args) { SpringApplication.run(MainApplication.class, args); } }
I expected DataSourceTransactionManagerAutoConfiguration to take care of this, but it is not. Any clues?
Sample up is on github: https://github.com/jangalinski/springboot-playground
spring spring-boot datasource
Jan Galinski
source share