gpt4 book ai didi

java - 如何在 Spring 的 application.properties 文件中定义 c3p0 属性

转载 作者:行者123 更新时间:2023-11-30 07:06:00 24 4
gpt4 key购买 nike

我想在 application.properties 文件中定义 c3p0 属性。但是 c3p0 属性似乎没有被识别。出了什么问题?是否有带有 c3p0 设置的 application.properties 文件示例?

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:jtds:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/${OPENSHIFT_APP_NAME}?autoReconnect=true
spring.datasource.username=${OPENSHIFT_MYSQL_DB_USERNAME}
spring.datasource.password=${OPENSHIFT_MYSQL_DB_PASSWORD}
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
c3p0.properties.driverClassName=com.mysql.jdbc.Driver
c3p0.properties.url=jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/${OPENSHIFT_APP_NAME}?autoReconnect=true
c3p0.properties.username=${OPENSHIFT_MYSQL_DB_USERNAME}
c3p0.properties.password=${OPENSHIFT_MYSQL_DB_PASSWORD}
c3p0.properties.acquire_increment=1
c3p0.properties.idle_test_period
c3p0.properties.timeout=14400
c3p0.properties.max_size=20
c3p0.properties.max_statements=50
c3p0.properties.min_size=3

最佳答案

以防万一还有人感兴趣...

它不适用于 application.properties。添加 c3p0.properties 文件有效。

c3p0.properties 示例:

c3p0.maxStatements=50
c3p0.acquireRetryDelay=3000

并且在 application.properties 中,您需要指定要使用的数据源类型:

spring.datasource.type=com.mchange.v2.c3p0.ComboPooledDataSource

关于java - 如何在 Spring 的 application.properties 文件中定义 c3p0 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26089917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com