0
から除外されたとき、私はブートアプリケーションでマルチテナンシーを実装している私は@SpringBootApplication
からDatasourceAutoconfiguration.classを除外している。このため、下記のリンクhttps://dzone.com/articles/spring-boot-hibernate-multitenancy-implementationはどのようにspring.datasourceを注入する。*プロパティをDataSourceAutoConfiguration.classが自動
に従うことによって、 like
@SpringBootApplication(
exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@EnableScheduling
@EnableJpaRepositories
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan("com.mps")
public class MpsServiceClientApplication {
問題は、カスタムデータソースにspring.datasource.tomcat.*
のようなプロパティをどのように注入するのですか?より正確には、カスタムデータソースに下記の2つのプロパティを設定する方法を教えてください。
spring.datasource.test-while-idle=true
spring.datasource.test-on-borrow=true
これは、jpaプロパティを設定する方法です。
final Map<String, Object> hibernateProps = new LinkedHashMap<>();
hibernateProps.putAll(this.jpaProperties.getProperties());
final LocalContainerEntityManagerFactoryBean result =
new LocalContainerEntityManagerFactoryBean();
result.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
result.setJpaPropertyMap(hibernateProps);