【发布时间】:2011-07-15 07:34:02
【问题描述】:
我通过在我的系统中安装 MySql 并在 X/lib 目录(其中 X 是我的应用程序名称)中放置了它的驱动程序,为 grails 中的 MySql 数据库进行了配置。我已更改 DataSource.groovy 以冲突更改。但是当我使用命令grails run-app 运行我的应用程序时,我收到了一个错误,因为
ERROR spring.BeanBuilder - WARNING: Your cache provider is set to 'com.opensymphony.oscache.hibernate.OSCacheProvider' in DataSource.groovy, however the class for this provider cannot be found.
Grails 开始使用它的内置数据库..
如何摆脱这个错误?
DataSource.groovy 代码是:
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "grails"
password = "server"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class =
'com.opensymphony.oscache.hibernate.OSCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
// one of 'create', 'create-drop','update'
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/racetrack_dev?autoreconnect=true"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/racetrack_dev?autoreconnect=true"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/racetrack_dev?autoreconnect=true"
}
}
}
提前致谢。
【问题讨论】:
-
你能添加你的 DataSource.groovy 文件和 excpetion 堆栈跟踪吗?
-
您应该将 BuildConfig.groovy 的连接器添加到
dependencies部分,如下所示:runtime 'mysql:mysql-connector-java:5.1.13';另外,你能发布你的 DataSource.groovy 吗? -
您是否更改了
grails-app/conf/Datasources.groovy文件以使url字段指向mysql? -
是的,我做了,并添加了
DataSource.groovy代码。