我是Grails的新手,我正在尝试从“Grails in Action”一书中学习。我有这个例子要求更改DataSource.groovy文件中的dataSource url,当我这样做时,我收到一个错误。以下是更改和错误。谁能帮我吗?提前谢谢,
前面的:
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
变更后:
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:hsqldb:file:devDB;shutdown=true"
错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor':
Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager':
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory':
Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'hibernateProperties':
Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dialectDetector':
Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:hsqldb:file:devDB;shutdown=true' (Use --stacktrace to see the full trace)
答案 0 :(得分:3)
您已将H2更改为HSQLDB - 您需要向BuildConfig.groovy添加相应的依赖项:
dependencies {
runtime 'hsqldb:hsqldb:1.8.0.10'
}
在DataSource.groovy中使用以下驱动程序:
driverClassName = "org.hsqldb.jdbcDriver"