我很难在 Grails 3 中设置HikariCP。
我唯一能意识到的就是application.yml/dataSource.pooled必须是false。剩下的有点神秘:
如何使用 Grails 3 设置 HikariCP?
所以我只是按预期工作。您需要做的就是包含 Hikari 依赖项,并在 application.yml 中设置 pooled: true。
可以通过在数据源的属性部分中指定它们来在 Hikari 连接池上设置其他属性
难道不是创造resources.groovy一个DataSource豆,因为这会导致各种各样的问题,如果合并设置为true,并且在很大程度上忽略,如果合并是假的(除了消费和离开空闲连接的整个池)
build.gradle 提取:
...
compile 'com.zaxxer:HikariCP:2.7.7'
...
Run Code Online (Sandbox Code Playgroud)
application.yml 提取:
...
dataSource:
pooled: true
driverClassName: "org.postgresql.Driver"
postgresql:
extensions:
sequence_per_table: false
logSql: false
dbCreate: ""
username: "username"
password: "password"
url: "jdbc:postgresql://..."
properties:
maximumPoolSize: 30
registerMbeans: true
connectionTimeout: 30000
...
Run Code Online (Sandbox Code Playgroud)
我不清楚 grails/gorm 如何检测连接池提供者,我不确定如果你配置了两个连接提供者会发生什么。我只是确保我的 build.gradle 中缺少默认的 tomcat 依赖项
# Remove this line from build.gradle if you have it
runtime 'org.apache.tomcat:tomcat-jdbc'
Run Code Online (Sandbox Code Playgroud)