如何找到Spring Boot的默认数据源连接池设置?

时间:2017-12-05 02:44:44

标签: mysql spring spring-boot

我正在构建一个需要连接到动态数据源的应用程序。我已修改配置类以声明数据源,如下所示:

public DataSource adminDataSource() {
    return DataSourceBuilder.create()
            .username(dataSourceUsername)
            .password(dataSourcePassword)
            .url(dataSourceUrl)
            .driverClassName(dataSourceDriver)
            .build();
}

但是,如果应用程序不受影响,则会发生超时:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 73,378,871 milliseconds ago.  The last packet sent successfully to the server was 73,378,871 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

我已将autoReconnect = true添加到连接网址,但这似乎仍然存在。通过属性文件配置的常规数据源不会发生这种情况。如何更改我的数据源配置以匹配默认连接池设置以防止这些超时?

0 个答案:

没有答案