为自定义数据源设置hikari池大小

时间:2019-07-22 10:17:58

标签: spring-boot hikaricp

我想为我的自定义数据源更改Hikari池大小,我使用的是Spring boot 2+版本。

我可以设置dataSource网址,dataSource密码等。 我将值写入了application.properties文件中,之后我使用environment.getproperty读取了这些值并设置了dataSource,但是我不知道池大小的相同过程:(

2 个答案:

答案 0 :(得分:0)

prefix<FORM>

您可以将最大池大小设置为10:

//Hide All Forms
$("form").hide();

//Use Class selector to attach event handler
$(".reply").click(function() {
    $(this) //Current element which invoked the event handler
     .closest('li') // First Ancestor LI element
     .children('form') //Immediate Child of LI element
     .toggle();
});
  

spring.datasource.hikari。* =#Hikari特定设置

它将自动设置您的游泳池大小

答案 1 :(得分:0)

我假设您通过设置DataSource bean来自定义dataSource。那么您可以按照以下步骤创建自定义hikariconfig,请记住将下面的硬代码值替换为您环境中的值。getproperty:

    @Bean
    public DataSource getDataSource() {

        HikariConfig config = new HikariConfig();
        config.setJdbcUrl("jdbc:mysql://yourhostname:port/dbname");
        config.setDriverClassName("com.mysql.jdbc.Driver");
        config.setUsername("dbUsername");
        config.setPassword("dbPassword");
        config.setMinimumIdle(10);
        config.setMaximumPoolSize(10);
        config.setConnectionTimeout(1500);
        //you can set more config here

        return new HikariDataSource(config);
    }