我在我的系统中安装了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"
}
}
}提前谢谢。
发布于 2011-07-15 07:59:34
您使用什么版本的grails来创建这个DataSource.groovy文件?
Grails 1.3.7的hibernate块如下所示:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}我想这能解释你的错误信息吗?(因为您已经将其设置为使用旧的OSCacheProvider
编辑
这些是我刚刚尝试过的步骤,所有这些都如预期的那样奏效了:
grails创建应用程序ants cd ants
grails-app/conf/BuildConfig.groovy文件,并取消对行的注释:mavenCentral()
和
运行时'mysql:mysql-connector-java:5.1.13'
grails-app/conf/DataSource.groovy。将dataSource块更改为:
dataSource {组合式=真driverClassName = "com.mysql.jdbc.Driver“用户名=”密码=“}
和url (在每个环境中)到
url = "jdbc:mysql://localhost:3306/ants?autoreconnect=true"
grails创建-域类ants.Runners
grails run-app
然后,当您检查DB时,您将得到一个runners表。
我猜您正在检查错误的数据库(每个环境都设置了dev、test和main db )。
https://stackoverflow.com/questions/6703903
复制相似问题