gpt4 book ai didi

grails - DataSource.groovy错误

转载 作者:行者123 更新时间:2023-12-02 15:00:55 24 4
gpt4 key购买 nike

我对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)

最佳答案

您已将H2更改为HSQLDB-您需要向BuildConfig.groovy添加相应的依赖项:

dependencies {
runtime 'hsqldb:hsqldb:1.8.0.10'
}

还可以在DataSource.groovy中使用以下驱动程序:
driverClassName = "org.hsqldb.jdbcDriver" 

关于grails - DataSource.groovy错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21616447/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com