Grails 审计日志记录:无法在 application.groovy 中解析 class grails.plugins.orm.auditable.AuditEventType

Grails Audit Logging: unable to resolve class grails.plugins.orm.auditable.AuditEventType in application.groovy

grails compile 无法解析 application.groovy 中的 grails.plugins.orm.auditable.AuditEventType

我已将插件包含在 build.gradle

build.gradle

dependencies {
    // ... other dependencies ...
    compile 'org.grails.plugins:audit-logging:4.0.3'
    // ... other dependencies ...
}

application.groovy

import grails.plugins.orm.auditable.AuditEventType

// ... other config ...

grails.plugin.auditLog.auditDomainClassName = "us.cloudcard.api.AuditLogEvent"
grails.plugin.auditLog.logFullClassName = false
grails.plugin.auditLog.defaultActor = "foo"
grails.plugin.auditLog.verbose = false
grails.plugin.auditLog.verboseEvents = [AuditEventType.UPDATE]

grails 编译

user@host dir % grails compile
| Error Error occurred running Grails CLI: startup failed:
script1644337921704582166752.groovy: 1: unable to resolve class grails.plugins.orm.auditable.AuditEventType
 @ line 1, column 1.
   import grails.plugins.orm.auditable.AuditEventType
   ^

1 error

我找到了解决方法。如果您删除导入并将完全限定的 class 名称放在配置项中,它可以正常工作。我不太喜欢这个,因为我不明白为什么它在导入不起作用时起作用。

application.groovy

// don't import AuditEventType

grails.plugin.auditLog.auditDomainClassName = "us.cloudcard.api.AuditLogEvent"
grails.plugin.auditLog.logFullClassName = false
grails.plugin.auditLog.defaultActor = "foo"
grails.plugin.auditLog.verbose = false
grails.plugin.auditLog.verboseEvents = [grails.plugins.orm.auditable.AuditEventType.UPDATE]