Grails 3.2.8域类中的依赖注入 [英] Grails 3.2.8 dependency injection in domain classes

查看:98
本文介绍了Grails 3.2.8域类中的依赖注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails 3.2.8在默认情况下似乎没有依赖注入为域类工作。

Grails 3.2.8 doesn't seem to have dependency injection working for domain classes by default.

当我创建一个新的应用程序并添加Spring Security Core 3.1时。 1与以下println:

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
}

我得到:

springSecurityService == null? true

如果我尝试创建并注入类似的服务,我会得到相同的空值。是否有一个很好的解决方法?

If I try creating and injecting a service similarly, I get the same null value. Is there a good workaround?

推荐答案

来重新启用它。Grame提到了一个针对spring的补丁-security-core来解决需要服务注入的问题,同时只需重新启用自动装配。

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.

请参阅我在3.2.8的非官方更新日志:
https://gist.github.com/erichelgeson/be2f9f62ab63d989f2ec962ae7001f21

See my unofficial changelog on 3.2.8 here: https://gist.github.com/erichelgeson/be2f9f62ab63d989f2ec962ae7001f21

这篇关于Grails 3.2.8域类中的依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆