SpelEvaluationException:EL1004E:方法调用:方法isAdmin()找不到

时间:2018-11-13 13:15:14

标签: java spring spring-boot spring-security

我正在尝试为springs @ PreAuthorize注释实现自定义授权功能。

代码如下:

控制器

@PreAuthorize("@localBeanChecker.isAdmin()")
@GetMapping("/contents")
public List<Content> index() {
    return manageContentService.fetchAllContent();
}

LocalBeanChecker

package project.configuration;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component(value = "localBeanChecker")
public class LocalBeanChecker {

    public boolean isAdmin() {
       return false;
    }
}

当我向/ contents请求时失败。

错误

org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method isAdmin() cannot be found on project.configuration.LocalBeanChecker type

我想念什么吗?

0 个答案:

没有答案