springboot - Spring interceptor中取不到@Value
本文介绍了springboot - Spring interceptor中取不到@Value的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
@Component
public class AuthorizeInterceptor extends HandlerInterceptorAdapter {
private Logger log = Logger.getLogger(AuthorizeInterceptor.class);
@Value("${usercenter.url.token}")
private String tokenValidateUrl;
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//这里tokenValidateUrl是null
return true;
}
是spring初始化顺序的问题吗?
解决方案
楼上是正确的解答,具体解决:
http://stackoverflow.com/ques...
这篇关于springboot - Spring interceptor中取不到@Value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文