grails - 从 grails 3.2 升级到 grails 3.3,GrailsDomainClass Api 已弃用

标签 grails grails-plugin grails-3.3

为了将我的应用程序和插件升级到 grails 3.3,我进行了以下替换。 (变量名称更改是为了提高替换的清晰度。)

Grails 3.2:

Class<?> clazz = grailsDomainClass.clazz
...

def grailsDomainClass = new DefaultGrailsDomainClass(clazz)
...

GrailsDomainClassProperty[] properties = grailsDomainClass.properties
...

def propertyName = grailsDomainClass.propertyName
...

def referenceType = grailsDomainClassProperty.referencedPropertyType
...

Grails 3.3:

Class<?> clazz = persistentEntity.javaClass
...

def persistentEntity = grailsApplication.mappingContext.getPersistentEntity(DomainClass.class.name)
...

PersistentProperty[] properties = persistentEntity.persistentProperties
...

def propertyName = persistentEntity.decapitalizedName
...

def referenceType = persistentProperty.type

其他更改位于 Grails 3.3 man .

女巫不清楚的是:

  1. 什么是替代品:

    grailsDomainClass.getPropertyValue(propertyName)
    
  2. 我应该把 doWithSpring 中的代码放在我的插件的什么地方?

手册页说:

The solution is to move any logic that executes before the context is available to somewhere else that executes after the context is available.

还有别的地方吗?是否有 doWithContext 闭包?可以用来注入(inject)bean吗?

最佳答案

  1. 使用ClassPropertyFetcher.getPropertyValue 方法

  2. doWithApplicationContext 是一种可用于覆盖插件的方法,您可以在其中放置逻辑。

关于grails - 从 grails 3.2 升级到 grails 3.3,GrailsDomainClass Api 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45797420/

相关文章:

hibernate - 如何使用 hibernate Envers触发实体onLoad()?

spring - 如何在 grails 中扩展 Spring Security 用户类?

hibernate - 如何将此SQL转换为Grails Gorm条件查询

Grails 与 Postgresql : can't create table in appropriate schema

asynchronous - Grails 3.3在集成测试期间进行了多个异步GORM调用,而没有访问数据库的权限。

Grails 资源插件和 cloudfoundry

grails - 我可以将服务注入(inject)到 Grails 的过滤器中吗?

mysql - Grails 2.5.0 + mongo + hibernate

grails - 如何使用 Grails Spring Security 插件在访问操作之前要求登录?

grails - Grails插件的正确Artifactory repo 结构?