grails3配置过滤器
Grails 3具有新的配置文件和格式。 新格式基于YAML,用于数据库配置的文件名为grails-app / conf / application.yml。 在Grails 1、1和2上开发应用程序后,我才刚刚开始使用Grails3。我期待着构建新的Grails 3应用程序。
在开始之前,我阅读了Grails 2到Grails 3的升级说明,并且感到非常自信。 但是,我昨天遇到一个问题,我想在这里描述一下,以防它对您有所帮助。
首先,这是application.yml的有效代码段,该代码段是为mySQL配置的数据源
dataSource:
pooled: true
jmxExport: true
# driverClassName: org.h2.Driver
driverClassName: com.mysql.jdbc.Driver
# dialect: org.hibernate.dialect.MySQL5InnoDBDialect
username: root
password: root
environments:
development:
dataSource:
# dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
dbCreate: create
url: jdbc:mysql://localhost/demo?autoReconnect=true
但是,这是您应该小心的地方。
确保您未在YAML文件中使用<variable_name> =“ <setting>”的旧格式。 我什么意思 好吧,这是一个例子:
dataSource:
pooled: true
jmxExport: true
# driverClassName: org.h2.Driver
driverClassName: com.mysql.jdbc.Driver
# dialect: org.hibernate.dialect.MySQL5InnoDBDialect
username: root
password: root
environments:
development:
dataSource:
# dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
dbCreate = "create"
url = "jdbc:mysql://localhost/demo?autoReconnect=true"
我以这种方式配置了Grails 3数据源,并且在grails运行应用程序启动时收到错误:
ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceInterceptor': Cannot resolve reference to bean 'hibernateDatastore' while setting bean property 'hibernateDatastore'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'hibernateDatastore' is defined
是的,回想起来,这令人尴尬。 我花了更多的时间进行调试,这超出了我的意愿。 因此,以防万一它可以帮助任何人,我正在为您写下来。
翻译自: https://www.javacodegeeks.com/2016/02/grails-3-datasource-configuration.html
grails3配置过滤器