我想在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
答案 0 :(得分:3)
以防有人仍然感兴趣...
它不适用于application.properties。添加c3p0.properties文件可以正常工作。
c3p0.properties示例:
c3p0.maxStatements=50
c3p0.acquireRetryDelay=3000
在application.properties中,您需要指定要使用的数据源类型:
spring.datasource.type=com.mchange.v2.c3p0.ComboPooledDataSource
答案 1 :(得分:0)
你试过吗
spring.jpa.properties.*
就像这样:
spring.jpa.properties.hibernate.c3p0.min_size = 5
我在28.3.3创建和删除JPA数据库
中找到28. Working with SQL databases