Spring Boot
hy.ding
这个作者很懒,什么都没留下…
展开
-
MockMvcTest
@RunWith(SpringRunner.class):SpringRunner继承类SpringJUnit4ClassRunnerpackage com.test;import com.test.service.CacheService;import org.junit.Assert;import org.junit.Before;import org.junit.Test;im...原创 2019-08-26 11:40:33 · 201 阅读 · 0 评论 -
Spring Boot @ExceptionHandler和@ControllerAdvice统一处理异常
package com.test.exception;import com.test.beans.ResultBean;import com.test.enums.StatusEnum;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.web.bind.annotation...原创 2019-08-23 17:08:30 · 450 阅读 · 0 评论 -
Spring Boot 自定义拦截器(HandlerInterceptor)使用@Autowired注入接口为null解决方法
在自定义拦截器代码中使用@Autowired注入CacheService为null配置信息代码package com.test.config;import com.test.interceptor.MyInterceptor;import org.springframework.context.annotation.Configuration;import org.springfram...原创 2019-08-23 13:06:18 · 2516 阅读 · 0 评论 -
自定义拦截器HandlerInterceptor
@Componentpublic class MyInterceptor implements HandlerInterceptor { private static Logger logger = LoggerFactory.getLogger(MyInterceptor.class); @Autowired private CacheService cacheSe...原创 2019-08-23 12:44:20 · 760 阅读 · 0 评论 -
Spring Boot 自定义ApplicationContextUtils 以及监视器@WebListener注解不生效处理方法
Spring Boot获取applicationcontext方案一:package com.test.util;import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.springframework.context....原创 2019-08-23 16:35:10 · 1632 阅读 · 0 评论