spring cloud 如何定义 Pivotal Cloud Foundry 下的验证间隔?
How spring cloud defines validation interval under the Pivotal Cloud Foundry?
我正在开发从 PCF (Pivotal Cloud FoundrY) 用户提供的服务获取 DS 的应用程序。它工作正常,但我想了解验证间隔是如何定义的。
因为 Spring 和 PCF 正在管理我的连接池。我想了解它是如何工作的。
public DataSource getProfileDS() {
PoolConfig poolConfig = new PoolConfig(5, 10, 30000);
DataSourceConfig dsConfig = new DataSourceConfig(poolConfig, null);
return connectionFactory().dataSource("profileDS", dsConfig);
}
另外,有没有办法像我们在tomcat下那样自己设置验证间隔?
How spring cloud defines validation interval under the Pivotal Cloud Foundry?
Spring Cloud Config 将定义适合您的关系数据库的验证查询。
示例:
至于验证间隔,看起来没有配置。相反,DBCP-like pools use testOnBorrow
, and Hikari 配置为使用 connectionTestQuery
。在从池中获取连接之前进行测试时,不需要设置验证间隔。
Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?
如果您要使用 Spring 云连接器则不需要,但您不必使用 Spring 云连接器。您还可以通过其他几种方式执行此操作。
- Spring 引导将
VCAP_SERVICES
公开为 vcap.services.<name>.credentials.username
等属性。您可以使用它们来手动定义数据源。参见 here。
- 您可以使用新的java-cfenv library, which is intended to complement Spring Boot better。
希望对您有所帮助!
我正在开发从 PCF (Pivotal Cloud FoundrY) 用户提供的服务获取 DS 的应用程序。它工作正常,但我想了解验证间隔是如何定义的。
因为 Spring 和 PCF 正在管理我的连接池。我想了解它是如何工作的。
public DataSource getProfileDS() {
PoolConfig poolConfig = new PoolConfig(5, 10, 30000);
DataSourceConfig dsConfig = new DataSourceConfig(poolConfig, null);
return connectionFactory().dataSource("profileDS", dsConfig);
}
另外,有没有办法像我们在tomcat下那样自己设置验证间隔?
How spring cloud defines validation interval under the Pivotal Cloud Foundry?
Spring Cloud Config 将定义适合您的关系数据库的验证查询。
示例:
至于验证间隔,看起来没有配置。相反,DBCP-like pools use testOnBorrow
, and Hikari 配置为使用 connectionTestQuery
。在从池中获取连接之前进行测试时,不需要设置验证间隔。
Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?
如果您要使用 Spring 云连接器则不需要,但您不必使用 Spring 云连接器。您还可以通过其他几种方式执行此操作。
- Spring 引导将
VCAP_SERVICES
公开为vcap.services.<name>.credentials.username
等属性。您可以使用它们来手动定义数据源。参见 here。 - 您可以使用新的java-cfenv library, which is intended to complement Spring Boot better。
希望对您有所帮助!