我的用戶域有一個名爲'lastLogin'的域,我想在登錄後自動更新(self-exaplantoy)。登錄後更新用戶的lastLogin屬性
groovy.lang.MissingMethodException:法無簽名: 重啓動Tomcat(DEV ENV)我得到下面的異常後靜態photoo.user.User.findById()是適用於參數類型:(java.lang中。長)的值:[2]可能的解決方案:的findAll(groovy.lang.Closure),找到(groovy.lang.Closure)
我使用在我Config.groovy中以下代碼:
// callback event, after a successful login
grails.plugins.springsecurity.onInteractiveAuthenticationSuccessEvent = { e, appCtx ->
def user = User.findById(appCtx.springSecurityService.principal.id)
User.withTransaction {
if(!user.isAttached())
user.attach()
user.lastLogin = new Date()
user.save(flush: true)
}
}
如何避免異常,爲什麼發生? thx