Grails 3.2.8 doesn't seem to have dependency injection working for domain classes by default.
When I create a new app and add Spring Security Core 3.1.1 with the following println:
protected void encodePassword() {
println "springSecurityService == null? ${(springSecurityService==null).toString()}"
password = springSecurityService?.passwordEncoder ? springSecurityService.encodePassword(password) : password
}
I get:
springSecurityService == null? true
If I try creating and injecting a service similarly, I get the same null value. Is there a good workaround?
Starting with Grails 3.2.8 autowiring of domain classes is disabled by default for performance reasons. You can re-enable it by setting
grails.gorm.autowire = true
Grame has mentioned a patch for spring-security-core to work around needing the service injection is coming, in the meantime just re-enable autowiring.
See my unofficial changelog on 3.2.8 here: https://gist.github.com/erichelgeson/be2f9f62ab63d989f2ec962ae7001f21