Grails error: return type getGrailsApplication () is incompatible

we upgrade grails 2.2.5 to grails 3.1 and get an interesting error. What does this mean and how should it be allowed?

/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. 
+5
source share
1 answer

Thank you for this issue .

"The controllers in Grails 2 and Grails 3 already have dependency injection for GrailsApplication, so you add a second. In Grails 2 it is not typed (def grailsApplication), and in Grails 3 it is typed (GrailsApplication grailsApplication) so you effectively added an override, but with a less specific return type that is invalid. Just remove your def grailsApplication and use one that already exists. "

If you simply remove def grailsApplication from all controllers, it will be fixed.

+5
source

All Articles