junit java.lang.NoClassDefFoundError: com/jayway/jsonpath/InvalidPathException

junit 测试的时候出现如下错误 在调用jsonpath方法出错

java.lang.NoClassDefFoundError: com/jayway/jsonpath/InvalidPathException     at org.springframework.test.web.servlet.result.JsonPathResultMatchers.<init>(JsonPathResultMatchers.java:43)     at org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(MockMvcResultMatchers.java:133)     at net.suntec.dynabiz.controller.MsgContentControllerTest.testInsertMsgContent(MsgContentControllerTest.java:94)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     at java.lang.reflect.Method.invoke(Method.java:597)     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)  

junit测试代码

@Test
public void testInsertMsg() throws Exception {
   
    mockMvc.perform(get("/msg/findmsgs", "json").accept(MediaType.APPLICATION_JSON)
            .param("title", "test222")
            ).andExpect(MockMvcResultMatchers.jsonPath("$.msgList",hasSize(1)));
     
}

解决方法,出现错误com/jayway/jsonpath/InvalidPathException

是缺少相应的jar包,需要下载json-path-0.8.1.jar

来源://作者:/更新时间:2014-02-22
相关文章
评论:
验证码:
匿名评论:

最新文章

新热推荐

文章排行