[英]Using Spring Cloud Connectors together with HikariCP
我想使用Spring Cloud Connectors中的HikariCP。 我不确定如何进行...
我已经将Spring Cloud Connectors更新为1.2.0.RC1。
这是我当前的配置:
@Configuration
@Profile({ Profiles.CLOUD })
public class CloudDataSourceConfiguration extends AbstractCloudConfig {
@Bean
public DataSource dataSource() {
int dbcpMaxActive = 10;
int dbcpMaxWait = 200;
PoolConfig poolConfig = new PoolConfig(dbcpMaxActive, dbcpMaxWait);
ConnectionConfig connectionConfig = new ConnectionConfig("sessionVariables=sql_mode='ANSI';characterEncoding=UTF-8");
DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig);
return connectionFactory().dataSource("CLEARDB_DATABASE", serviceConfig);
}
}
有人可以请教吗?
编辑 :当我使用云配置文件启动应用程序时,我可以阅读
2015-05-23 22:46:56,029 [localhost-startStop-1] INFO org.springframework.cloud.service.relational.PooledDataSourceCreator - Found Tomcat high-performance connection pool on the classpath. Using it for DataSource connection pooling.
从日志输出。
编辑2 :HikariCP在类路径中,似乎tomcat高性能连接池也在类路径中。
如我第二次编辑所述,tomcat jdbc和HikariCP都在类路径上。 通过如下删除tomcat jdbc(在我的gradle脚本中):
compile("org.springframework.boot:spring-boot-starter-data-jpa"){
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
}
只有HikariCP保留在类路径上,并且如下面的日志输出所示正确地将其拾取 :
INFO org.springframework.cloud.service.relational.PooledDataSourceCreator - Found HikariCP on the classpath. Using it for DataSource connection pooling.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.