簡體   English   中英

將Spring Cloud連接器與HikariCP結合使用

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM