grails error: return type of getGrailsApplication() is incompatible
grails error: return type of getGrailsApplication() is incompatible
我们正在将 grails 2.2.5 应用程序升级到 grails 3.1,但出现了一个有趣的错误。这是什么意思,应该如何解决?
/myapp/grails-app/controllers/myapp/admin/AdminProjectController.groovy: -1:
The return type of java.lang.Object getGrailsApplication() in myapp.admin.AdminProjectController is incompatible with grails.core.GrailsApplication in grails.web.api.WebAttributes
. At [-1:-1] @ line -1, column -1.
感谢 burtbeckwith issue。
"Controllers in Grails 2 and Grails 3 already have an implicit dependency injection for GrailsApplication, so you're adding a second. In Grails 2 it's not typed (def grailsApplication) but in Grails 3 it is typed (GrailsApplication grailsApplication), so you've effectively added an override, but with a less specific return type which is invalid. Just delete your def grailsApplication and use the one that's already there."
如果您只是从所有控制器中删除 def grailsApplication
,它将得到修复。
我们正在将 grails 2.2.5 应用程序升级到 grails 3.1,但出现了一个有趣的错误。这是什么意思,应该如何解决?
/myapp/grails-app/controllers/myapp/admin/AdminProjectController.groovy: -1:
The return type of java.lang.Object getGrailsApplication() in myapp.admin.AdminProjectController is incompatible with grails.core.GrailsApplication in grails.web.api.WebAttributes
. At [-1:-1] @ line -1, column -1.
感谢 burtbeckwith issue。
"Controllers in Grails 2 and Grails 3 already have an implicit dependency injection for GrailsApplication, so you're adding a second. In Grails 2 it's not typed (def grailsApplication) but in Grails 3 it is typed (GrailsApplication grailsApplication), so you've effectively added an override, but with a less specific return type which is invalid. Just delete your def grailsApplication and use the one that's already there."
如果您只是从所有控制器中删除 def grailsApplication
,它将得到修复。