为了将我的应用程序和插件升级到 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 .
女巫不清楚的是:
什么是替代品:
grailsDomainClass.getPropertyValue(propertyName)
我应该把
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吗?
最佳答案
使用
ClassPropertyFetcher.getPropertyValue
方法doWithApplicationContext
是一种可用于覆盖插件的方法,您可以在其中放置逻辑。
关于grails - 从 grails 3.2 升级到 grails 3.3,GrailsDomainClass Api 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45797420/