Wygląda na to, że czegoś brakuje: Automatyczne wstrzykiwanie źródła danych działa, ale wstrzyknięcie DataSourceTransactionManager kończy się niepowodzeniem.Spring-boot: automatyczna konfiguracja menedżera transakcji
zależności:
<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>
Kod:
@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);
}
}
Spodziewałem się, że DataSourceTransactionManagerAutoConfiguration będzie dbać o to, ale tak się nie stało. Jakieś wskazówki?
Próbka się to na github: https://github.com/jangalinski/springboot-playground
Dobra, dzięki ... powinnaś była wcześniej zapytać. –
PlatformTransactionManager jest autokonfigurowalny w Spring boot? Ponieważ musimy tworzyć komponenty bean w ramach Spring Framework. – Deepak