In Spring Boot,
if you define another data source,
the default data source won't be created.
So you have to define your original data source as a bean as follows:
@Configuration
public class DataSourceConfig {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
}
If you use JPA,
you should use @Primary annotation for auto-configuration.
Reference:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-two-datasources
No comments:
Post a Comment