【发布时间】:2015-04-24 04:52:04
【问题描述】:
似乎我遗漏了一些东西:自动注入数据源有效,但注入 DataSourceTransactionManager 失败。
依赖关系:
<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>
代码:
@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);
}
}
我预计 DataSourceTransactionManagerAutoConfiguration 会处理它,但它没有。有什么线索吗?
示例在 github:https://github.com/jangalinski/springboot-playground
【问题讨论】:
标签: spring datasource spring-boot