最近项目推进中
在进行Junit单体测试的时候出现标题问题
具体问题如下
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.test.context.web.WebDelegatingSmartContextLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
之前遇到过一次,解决掉没记录,现在记录下来,避免再出现相同问题
解决方案
在pom.xml里添加
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>test</scope> </dependency>
缺少这个依赖,加上就好了