我使用的是Grails 2.0,並且無法使代碼識別外部庫。特別是MySQL驅動程序。在Grails 2.0中使用MySQL - 查找外部連接器.jar
基本上,每當我嘗試將我的數據源從HSQLDB更改爲MySql時都會發生問題。我下載了連接器jar(5.0.8)並將它放在(project)/ lib目錄中。我已驗證com.mysql.jdbc.Driver.class文件位於.jar中。
每次我嘗試運行應用程序,我得到的錯誤:
造成的ClassNotFoundException:com.mysql.jdbc.Driver
任何幫助是極大的讚賞。
dataSource {
pooled = true
//driverClassName = "org.h2.Driver"
//username = "sa"
//password = ""
driverClassName = "com.mysql.jdbc.Driver"
username = "bob"
password = "password"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
//dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:mem:devDb;MVCC=TRUE"
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/tekevent"
}
}
test {
dataSource {
dbCreate = "create-drop"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
您是否嘗試從命令行執行'grails clean'? –