问题原因

拦截器加载的时间点在springcontext之前,所以在拦截器中注入自然为null

文件解决

在spring配置文件中这样写

1
2
3
4
5
6
7
8
9
10
@Bean
   public HandlerInterceptor getMyInterceptor(){
       return new MyInterceptor();
   }
 
   @Override
   public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(getMyInterceptor());
       super.addInterceptors(registry);
   }

  

 

使用bean注解提前加载,即可成功。

posted @ 2018-08-29 16:16 小锋神 阅读(2165) 评论(0) 推荐(0) 编辑
摘要: 转自: https://www.cnblogs.com/wmyskxz/p/9010832.html Spring Boot 概述 Build Anything with Spring Boot:Spring Boot is the starting point for building all S 阅读全文
posted @ 2018-08-29 15:41 小锋神 阅读(828) 评论(0) 推荐(0) 编辑
摘要: 转自: https://www.cnblogs.com/wmyskxz/p/9010832.html Spring Boot 概述 Build Anything with Spring Boot:Spring Boot is the starting point for building all S 阅读全文
posted @ 2018-08-29 15:41 小锋神 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 1. pom文件的驱动jar包加上去, 2. application.yml 注意不要使用url,要使用jdbc-url 主数据库配置: 第二数据库配置: 阅读全文
posted @ 2018-08-29 10:33 小锋神 阅读(17158) 评论(2) 推荐(0) 编辑
摘要: List<User> list = new ArrayList<User>(); User user1 = new User("第一位","用户1"); list.add(user1); User user2 = new User("第二位","用户2"); list.add(user2); Use 阅读全文
posted @ 2018-08-06 15:24 小锋神 阅读(13639) 评论(0) 推荐(1) 编辑
摘要: 阅读全文
posted @ 2018-07-19 12:42 小锋神 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 2017年11月23日 09:18:03 阅读数:306 2017年11月23日 09:18:03 阅读数:306 阅读数:306 一.环境说明 Windows 10 1709 Spring 4.3.12.RELEASE FastJson 1.2.40 IDEA 2017.3 JDK 1.8.0_1 阅读全文
posted @ 2018-07-04 10:03 小锋神 阅读(1484) 评论(0) 推荐(0) 编辑
摘要: java中的定时任务, 使用java实现有3种方式: 1, 使用普通thread实现 2, 使用timer实现: 可控制启动或取消任务, 可指定第一次执行的延迟 线程安全, 但只会单线程执行, 如果执行时间过长, 就错过下次任务了, 抛出异常时, timerWork会终止 3, 使用 Schedul 阅读全文
posted @ 2018-07-03 14:59 小锋神 阅读(632) 评论(0) 推荐(0) 编辑
摘要: 转自: https://www.cnblogs.com/Fndroid/p/6087380.html Java8已经推出了好一段时间了,而掌握Java8的新特性也是必要的,如果要进行Spring开发,那么可以发现Spring的官网已经全部使用Java8来编写示例代码了,所以,不学就看不懂。 这里涉及 阅读全文
posted @ 2018-06-27 11:04 小锋神 阅读(525) 评论(0) 推荐(0) 编辑
摘要: 转自: http://blog.csdn.net/wilsonke/article/details/24362851 作用一种简单方便的数据传输方案,JSON已经成为替代XML的事实标准。然而在JSON中,时间(DateTime,Timestamp,Date等)格式一直没有很好地统一,当需要跨平台序 阅读全文
posted @ 2018-06-26 11:15 小锋神 阅读(2013) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示