【发布时间】:2017-05-28 01:31:03
【问题描述】:
我有一个使用 grails 2.2.4 和 hibernate 3 的项目。我正在将它迁移到使用 hibernate 5 的 grails 3.2.4。我从头开始创建一个 grails 3.2.4 项目,现在我是慢慢地从旧项目中复制一小部分代码并使其正常工作。起初,我只复制了我的 User、UserRole 和 Role 类,并让我的整个 Spring Security 登录流程正常工作。然后,我复制了剩余的域对象并尝试启动我的项目。我的域对象使用 GORM 映射,而不是 JPA 注释。该项目现在甚至不会启动,并且在启动时会出现以下异常(我链接到一个公共要点,因为内容对于堆栈溢出允许的内容来说太长了)。
https://gist.github.com/schmickie/10522d3a2b8a66b6fb79f76e2af0fd72
我在网上搜索了一些错误,我能找到的所有内容都表明它与设置复合主键的问题有关。但是,我没有使用任何复合主键。有人知道出了什么问题吗?错误中引用的领域对象,Api 和 Method,如下所示。
class Api implements Serializable {
String name
boolean enabled
String apiVersion
String swaggerVersion
String resourcePath
String jsonData
boolean https = true
String regionSource
String contractName
String contractBasePath
Date dateCreated
Date lastUpdated
Date deprecationDate
static hasMany = [methods: Method, models: Model, apiServers: ApiServer]
static mapping = {
cache true
}
static constraints = {
name(nullable: false, blank: false)
enabled()
apiVersion(nullable: true, blank: true)
resourcePath(nullable: true, blank: true)
swaggerVersion(nullable: true, blank: true)
jsonData(type: 'text', nullable: true, blank: true)
dateCreated()
lastUpdated()
deprecationDate(nullable: true)
regionSource(nullable: true)
contractName(nullable: true)
contractBasePath(nullable: true)
}
public Method getMethod(String name) {
for (Method method : methods) {
if (method.name.equals(name)) {
return method
}
}
return null
}
}
class Method implements Serializable, Comparable<Method> {
String name
boolean enabled
String edgePath
HttpMethodEnum edgeHttpMethod
String servicePath
HttpMethodEnum serviceHttpMethod
String summary
String notes
boolean deprecatedMethod
String responseClass
SortedSet<EdgeParameter> edgeParameters
SortedSet<ServiceParameter> serviceParameters
Date dateCreated
Date lastUpdated
String publicResponseTransformScript
String baseResponseTransformScript
String regionFieldName
String platformFieldName
String apiKeyFieldName
String uriTransformScript
long cacheExpiry
static belongsTo = [api: Api]
static hasMany = [edgeParameters: EdgeParameter, serviceParameters: ServiceParameter, errorResponses: ApiErrorResponse]
static mapping = {
cache true
errorResponses sort: 'code', order: "asc"
}
static constraints = {
name(blank: false)
enabled()
edgePath(nullable: false, blank: false)
edgeHttpMethod(nullable: false, blank: false)
servicePath(nullable: false, blank: false)
serviceHttpMethod(nullable: false, blank: false)
summary(nullable: false, blank: false)
notes(nullable: true, blank: true)
deprecatedMethod()
responseClass(nullable: true, blank: true)
publicResponseTransformScript(nullable: true)
baseResponseTransformScript(nullable: true)
regionFieldName(nullable: true)
platformFieldName(nullable: true)
apiKeyFieldName(nullable: true)
uriTransformScript(nullable: true)
cacheExpiry(nullable: false, blank: true)
}
}
【问题讨论】:
-
该问题与 Error created bean with name 'springSecurityUiInterceptor.如果是这个弹簧安全和弹簧安全 ui 插件,你可以禁用 ui 插件作为测试吗?
-
是什么让您认为它与 springSecurityUiInterceptor bean 有关系?顺便说一句,在弄清楚之后,我已经在下面发布并接受了我自己的答案。我向grails项目提交了一个PR,让错误信息更清晰,已经合并了。
-
我认为这是该行的要点链接上的错误日志:01/12/2017 11:17:37 PST WARN main AbstractApplicationContext:550 - 错误从 springSecurityUiInterceptor 开始..但是这显然是一个仓促的答案,可能有点像在安装了 spring security 之后,任何错误返回似乎都与 spring security 相互关联,初学者可能会认为这是 spring security 当它是其他问题但现在嵌入在 spring 中时安全
标签: hibernate grails grails-orm