No bean resolver registered in the context to resolve access to bean

北城以北 提交于 2019-12-01 02:40:50

You need to ensure that you set the ApplicationContext on the DefaultMethodSecurityExpresssionHandler. For example:

@Autowired
private ApplicationContext context;

@Override
protected MethodSecurityExpressionHandler expressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler =
            new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(appPermissionEvaluator());
    handler.setApplicationContext(context);
    return handler;
}

Alternatively and more concisely, if you define a single PermissionEvaluator as a Bean and Spring Security will automatically pick it up (no need to override expressionHandler()). For example:

@Bean
public PermissionEvaluator appPermissionEvaluator() {
    ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!