2017-09-04 115 views
1

我的应用程序使用下面的框架和应用服务器:如何跟上春天开机,休眠和WebSphere Application Server连接

  1. 春季启动(1.5.4.RELEASE)与休眠。

  2. 的WebSphere Application Server自由的Java上Bluemix

应用程序工作正常,但后小时连接超时运行。请参阅以下例外:

2017-09-01T11:40:40.57+0900 [APP/PROC/WEB/0] OUT 2017-09-01 02:40:40,563 [http-nio-8080-exec-2] [5baba2cb-5bfd-4846-b8e0-8782aa729639] [] WARN o.h.e.jdbc.spi.SqlExceptionHelper [SqlExceptionHelper.java:127] - SQL Error: -4499, SQLState: 08001 
2017-09-01T11:40:40.58+0900 [APP/PROC/WEB/0] OUT or socket output stream. Error location: Reply.fill() - socketInputStream.read (-1). Message: Connection timed out (Write failed). ERRORCODE=-4499, SQLSTATE=08001 

我知道Spring引导需要在application.properties中设置配置属性。

spring.datasource.testOnBorrow=true 
spring.datasource.testWhileIdle=true 
spring.datasource.timeBetweenEvictionRunsMillis=60000 
spring.datasource.numTestsPerEvictionRun=3 
spring.datasource.minEvictableIdleTimeMillis=600000 
spring.datasource.validationQuery=SELECT 1 

然而,我发现同春启动1.3+,我们必须用他们各自的前缀(spring.datasource.tomcat。,spring.datasource.hikari。,春季使用的特定实现设置。 datasource.dbcp2。*)和(显然)不支持Websphere Application Server Liberty Profile。

我的问题是我应该如何配置以保持连接活着(或更新它们)?

预先感谢您!

+0

实现取决于你的数据源而不是你的应用服务器。从您使用'spring.datasource'的事实判断,我假设您没有使用'spring.datasource.jndi-name',因此您正在使用其中一个受支持的连接池。如果没有,'spring.datasource'属性(除了'jndi-name'之外)几乎没有用,因为应该在你的应用服务器中配置这些属性。 –

+0

谢谢你的帮助!正如您所设想的,我使用'spring.datasource.url'而不是'spring.datasource.jndi-name'。当我使用'spring.datasource.url'时,有没有办法激活'spring.datasource。*'属性? @ M.Deinum –

回答

0

您使用的是什么数据源?在我们的例子中,我们使用的是默认选项tomcat。所以我们有

# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) 
spring.datasource.tomcat.test-on-borrow=true 
spring.datasource.tomcat.test-while-idle=true 
spring.datasource.tomcat.time-between-eviction-runs-millis=300000 
spring.datasource.tomcat.validation-query=SELECT 1