events - 使用Spring Security Core插件和Grails 2.0.0注册事件监听器时出错

标签 events authentication grails groovy spring-security

我正在尝试注册事件监听器以成功登录,以便在我知道用户刚刚通过身份验证时可以执行一些逻辑。根据 Spring 安全文档,即时注册事件如下:

package grails.admin

import org.springframework.context.ApplicationListener
import org.springframework.security.authentication.event. AuthenticationSuccessEvent

class SuccessfulAuthenticationEventListener implements ApplicationListener<AuthenticationSuccessEvent> {

    void onApplicationEvent(AuthenticationSuccessEvent event){
        System.out.println("THERE WAS A SUCCESSFUL LOGIN");
    }

}

然后按照以下步骤在config.groovy中进行连接:
import grails.admin.SuccessfulAuthenticationEventListener
beans = {
    successfulAuthenticationEventListener(SuccessfulAuthenticationEventListener)
}

当我运行项目时,它崩溃并显示以下消息:
[Thread-9] ERROR context.GrailsContextLoader  - Error executing bootstraps: Cannot cast object 'Config$_run_closure5@4eff1d61' with class 'Config$_run_closure5' to class 'groovy.util.ConfigObject'

香港专业教育学院谷歌搜索错误没有运气,现在转向你的好人!兼容性是否存在问题,我将不得不使用其他方法来做到这一点?

最佳答案

resources.groovy用于注册其他spring bean。您必须将bean定义放在resources.groovy中,而不是config.groovy中

关于events - 使用Spring Security Core插件和Grails 2.0.0注册事件监听器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9273068/

相关文章:

json - WSO2 API Manager Auth 错误内容类型

Java 执行回调时删除监听器

C# 从控件列表引发事件

javascript - 如何向 jQuery 的 on() 回调添加事件?

macos - 让 NSWindow 拒绝键盘事件

hibernate - 是否可以从单个线程抛出StaleStateObjectException?

reactjs - 使用NextJS和Auth0时如何添加共享布局?

asp.net-mvc - User.Identity.IsAuthenticated 始终为 True

caching - Grails/Tomcat : Avoiding denial of service attacks

hibernate - 无论如何,是否要检查域类中的属性是否为主键?