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

时间:2017-08-21 12:41:11

标签: grails grails-plugin grails-3.3

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

Grails 3.2:

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:

grailsDomainClass.getPropertyValue(propertyName)

其他更改位于Grails 3.3 man

女巫不清楚是:

  1. 有什么替代品:

    doWithSpring
  2. 我在哪里将doWithContext中的代码放在我的插件上?

  3. 手册页说:

      

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

    其他地方是谁?是否有servers:{Name : string , Id:number }[]=[]; ngOnInit() { this.Id = this.route.snapshot.params['id']; } 封闭?它可以用来注入bean吗?

1 个答案:

答案 0 :(得分:2)

  1. 使用ClassPropertyFetcher.getPropertyValue方法

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