在HikariPool中关闭异常日志记录

时间:2018-10-25 12:15:42

标签: spring-boot jpa spring-data-jpa hikaricp

我有两个连接到我的应用程序的数据库,因此有两个类似的连接器:

C1

问题在于,此特定连接器仅应在生产环境中工作,因为它使用客户端数据(位于内部本地网络中并且无法在客户端网络外部访问)连接到数据库。现在,在我的本地环境中开发时,两个连接器都启动了,因此此@Configuration @EnableTransactionManagement @EnableJpaRepositories(entityManagerFactoryRef = DMP_SAP_ENTITY_MANAGER_FACTORY_BEAN_NAME) class SapHanaConnectionConfiguration @Autowired constructor(private val environment: Environment) { private val driverClassName by lazy { environment.getProperty(DMP_SAP_DRIVER_CLASS_NAME) } private val jdbcString by lazy { environment.getProperty(DMP_SAP_JDBC_STRING) } private val username by lazy { environment.getProperty(DMP_SAP_USERNAME) } private val password by lazy { environment.getProperty(DMP_SAP_PASSWORD) } @Bean(name = [DMP_SAP_DATA_SOURCE_BEAN_NAME]) fun dataSource(): DataSource = DataSourceBuilder.create() .driverClassName(driverClassName) .url(jdbcString) .username(username) .password(password) .build() @Bean(name = [DMP_SAP_ENTITY_MANAGER_FACTORY_BEAN_NAME]) fun entityManagerFactory( builder: EntityManagerFactoryBuilder, @Qualifier(DMP_SAP_DATA_SOURCE_BEAN_NAME) dataSource: DataSource ): LocalContainerEntityManagerFactoryBean = builder .dataSource(dataSource) .packages(DMP_SAP_MODEL_PACKAGE) .persistenceUnit(DMP_SAP_PERSISTENCE_UNIT_NAME) .build() @Bean(name = [DMP_SAP_TRANSACTION_MANAGER_BEAN_NAME]) fun transactionManager(@Qualifier(DMP_SAP_ENTITY_MANAGER_FACTORY_BEAN_NAME) entityManagerFactory: EntityManagerFactory): PlatformTransactionManager = JpaTransactionManager(entityManagerFactory) } 引发异常,因为它无法建立与给定DB的连接。

SapHanaConnection

我想以某种方式说这个连接器应该仅在某些配置文件处于活动状态时才运行,这可能吗?

我正在将Spring Boot与Kotlin一起使用。

0 个答案:

没有答案