我正在尝试使用MockMVC设置Junit测试.
从这个link – “要么不能使用Servlet API,要么你需要在类路径上提供它”.
这是跟踪
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.test.context.web.WebDelegatingSmartContextLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:130)
at org.springframework.test.context.ContextLoaderUtils.resolveContextLoader(ContextLoaderUtils.java:118)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:594)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:560)
at org.springframework.test.context.TestContext.
好的,根据评论更新,所以我把范围改为编译然后似乎通过了找不到类的问题!
最佳答案
原文链接:https://www.f2er.com/spring/432587.html