【问题标题】:Upgrade from grails 3.2 to grails 3.3, GrailsDomainClass Api Deprecated从 grails 3.2 升级到 grails 3.3,不推荐使用 GrailsDomainClass Api
【发布时间】:2018-01-29 13:07:30
【问题描述】:

我进行了以下替换以将我的应用程序和插件升级到 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 中的代码放在我的插件上的什么位置?

手册页说:

解决方案是将在上下文可用之前执行的任何逻辑移动到在上下文可用之后执行的其他地方。

其他地方?有doWithContext 关闭吗?可以用来注入bean吗?

【问题讨论】:

    标签: grails grails-plugin grails-3.3


    【解决方案1】:
    1. 使用ClassPropertyFetcher.getPropertyValue方法

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

    【讨论】:

    • 在 grails 数据存储 6.0.9 org.grails.datastore.mapping.reflect.ClassPropertyFetcher 中可以返回非静态属性值。但在 6.1.6 中只能提取静态属性值。发生了什么变化?
    猜你喜欢
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多