参考:https://www.cnblogs.com/SimonHu1993/p/8360701.html

一定要将 拦截器组件 交给spring容器进行管理,这样才能注入配置值,或者注入bean:

package com.thunisoft.maybeemanagementcenter.interceptor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration
public class WebAppConfigure extends WebMvcConfigurerAdapter { @Value("${thunisoft.microservice.mvc.interceptor.includePath:/**}")
private String includePath;
@Value("${thunisoft.microservice.mvc.interceptor.excludePath:/login/*}")
private String excludePath; @Override
public void addInterceptors(InterceptorRegistry registry) {
String[] excludePaths = excludePath.split(",");
String[] includePaths = includePath.split(",");
InterceptorRegistration ir = registry.addInterceptor(loginInterceptor())
.addPathPatterns(includePaths)
.excludePathPatterns(excludePaths);
super.addInterceptors(registry);
} @Bean
public LoginInterceptor loginInterceptor() {
return new LoginInterceptor();
}
}

重点代码:

@Bean
public LoginInterceptor loginInterceptor() {
return new LoginInterceptor();
}
registry.addInterceptor(loginInterceptor())

spring boot 使用拦截器 无法注入 配置值 、bean问题的更多相关文章

  1. spring boot 使用拦截器,注解 实现 权限过滤

    http://www.cnblogs.com/zhangXingSheng/p/7744997.html spring boot 使用拦截器 实现 用户登录拦截 http://www.cnblogs. ...

  2. Spring boot自定义拦截器和拦截器重定向配置简单介绍

    大家好: 本文简单介绍一下用于权限控制的Spring boot拦截器配置,拦截器重定向问题. 开发工具:jdk1.8   idea2017(付费版,网上找的破解教程) 1,首先使用idea创建一个Sp ...

  3. Spring Boot之拦截器与过滤器(完整版)

    作者:liuxiaopeng 链接:http://www.cnblogs.com/paddix 作者:蓝精灵lx原文:https://blog.csdn.net/liuxiao723846/artic ...

  4. Spring Boot整合拦截器

    过滤器和监听器都属于Servlet 的api,还可以使用 Spring 提供的拦截器(HandlerInterceptor)进行改更精细的控制.

  5. spring boot 添加拦截器

    构建一个spring boot项目. 添加拦截器需要添加一个configuration @Configuration @ComponentScan(basePackageClasses = Appli ...

  6. spring boot 添加拦截器的简单实例(springBoot 2.x版本,添加拦截器,静态资源不可访问解决方法)

    spring中拦截器主要分两种,一个是HandlerInterceptor,一个是MethodInterceptor 一.HandlerInterceptor HandlerInterceptor是s ...

  7. 【第四十章】Spring Boot 自定义拦截器

    1.首先编写拦截器代码 package com.sarnath.interceptor; import javax.servlet.http.HttpServletRequest; import ja ...

  8. Spring Boot (20) 拦截器

    动态资源和静态资源 拦截器可以算是aop的一种实现,专门拦截对动态资源的后台请求,也就是拦截对控制层的请求,主要用于判断用户是否有权限请求后台.拦截器不会拦截静态资源,如spring boot默认静态 ...

  9. spring boot使用拦截器

    1.编写一个拦截器 首先,我们先编写一个拦截器,和spring mvc方式一样.实现HandlerInterceptor类,代码如下 package com.example.demo.intercep ...

随机推荐

  1. 怎么在eclipse中安装svn插件

    Subclipse   Subclipse is an Eclipse Team Provider plug-in providing support for Subversion within th ...

  2. php分享十五:php的命令行操作

    一:像命令行传参数方法: 1: 使用$argc $argv 用法: /usr/local/php/bin/php ./getopt.php 123  456 2:使用getopt函数() http:/ ...

  3. KMP算法理解

    1.KMP算法解决问题:对BF(Brute Force)算法优化,避免对主串进行回溯匹配(匹配不成功主串指针向后移1位,子串指针重置开始位置,两串继续匹配),效率底. 2.KMP算法原则/目的:主串不 ...

  4. [转]在 javascript 按键事件中,按键值的对照表

    转自:http://www.phpweblog.net/kiyone/archive/2007/04/19/1138.html 话说谁知道怎么能精简下word生成的html代码....好大啊... 字 ...

  5. 【Unity】6.7 向量和Vector3类

    分类:Unity.C#.VS2015 创建日期:2016-04-20 一.简介 在虚拟的游戏世界中,与3D有关的数学知识决定了游戏引擎如何计算和模拟出开发者以及玩家看到的每一帧画面.学习或者回想一下基 ...

  6. listview 两个Item可以同时点击

    android:splitMotionEvents="false" ListView的这个属性可以限制它不能同时点击两个Item

  7. Android异步载入学习笔记之四:利用缓存优化网络载入图片及ListView载入优化

    假设不做不论什么处理.直接用网络载入图片在网速快的情况下可能没什么不好的感觉.可是假设使用移动流量或是网络不好的时候.问题就来了,要么用户会抱怨流量使用太多.要么抱怨图片载入太慢.如论从哪个角度出发, ...

  8. TF-IDF理解及其Java实现

    TF-IDF 前言 前段时间,又具体看了自己以前整理的TF-IDF,这里把它发布在博客上,知识就是需要不断的重复的,否则就感觉生疏了. TF-IDF理解 TF-IDF(term frequency–i ...

  9. Kudu:支持快速分析的新型Hadoop存储系统

    Kudu 是 Cloudera 开源的新型列式存储系统,是 Apache Hadoop 生态圈的新成员之一( incubating ),专门为了对快速变化的数据进行快速的分析,填补了以往 Hadoop ...

  10. FFmpeg Basic学习笔记(4)

    图像处理 常见的图片格式包括YUV.BMP.JPG.GIF.PNG. 图像的创建 可以使用下面命令从输入源中截取图像 ffmpeg -i input -ss t image.type 从videocl ...