在来自控制器的以下代码片段中,我在尝试访问 springSecurityService.currentUser 时收到空指针异常。我希望 def springSecurityService 自动注入服务,我错过了什么?
@Transactional(readOnly = true)
@Secured('ROLE_USER')
class TaskController {
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
def index(Integer max) {
params.max = Math.min(max ?: 10, 100)
def springSecurityService
def user = springSecurityService.currentUser