当DB关闭时,我的应用程序卡住了。我们的场景是,当DB关闭时,我们应该从另一个API获取数据。应用程序停止在
2023-07-26 13:00:25 [schedule-1] INFO(c.z.h.HikariDataSource:110)- HikariPool-1 - Starting...
我的房产:
spring:
profiles: dv1
datasource:
jdbc-url: ${odsdb.dbname}
username: ${odsdb.userid}
password: ${odsdb.passwd}
driver-class-name: oracle.jdbc.OracleDriver
test-on-borrow: true
hikari:
connectionTimeout: 30000
idleTimeout: 60000
maxLifetime: 180000
maximumPoolSize: 30
poolName: ns-hirakiri-pool
connectionTestQuery: SELECT 1
initialization-fail-fast: false
@Bean
@ConfigurationProperties(prefix = "datasource")
public DataSource dataSource() {
DataSource dataSource = null;
try {
dataSource = DataSourceBuilder.create().build();
} catch (Exception e) {
LOG.info("Unable to get DataSource:", e);
}
return dataSource;
}
public Connection getOracleDbConnection() {
Connection con = null;
try {
DataSource dataSource = (DataSource) AppContext.getContext().getBean(AddressConstants.DATA_SOURCE);
con = dataSource.getConnection();
log.info("In getOracleDbConnection Connection:"+con);
} catch (SQLException e) {
log.info("Failed to acquire a database connection: {}", e.getMessage());
} catch (Exception se) {
log.info("Exception in getOracleDbConnection", se);
}
return con
}
字符串
我们的应用程序没有启动。即使我将initialization-fail-fast设置为false,它仍然会卡住。你能提供任何帮助吗?
如何超越hikaridatasource设置,即使数据库关闭?
1条答案
按热度按时间qij5mzcb1#
我相信你可以把财产
字符串
在你的application.properties文件中。这应该允许spring的快速故障特性被克服并继续应用程序启动。