Druid版本:1.1.3、1.1.4 配置如下(其他默认):
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/db
username: username
password: password
测试代码如下:
public class UserControllerTest {
@Resource
private MockMvc mvc;
@Test
public void testGet() throws Exception {
mvc.perform(get("/").accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk());
}
}
错误如下:
java.lang.NullPointerException
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:94)
at org.springframework.test.web.servlet.setup.PatternMappingFilterProxy.doFilter(PatternMappingFilterProxy.java:101)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:134)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
……