错误信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcContentNegotiationManager': Failed to introspect bean class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
解决方案:
单元测试在pom文件中加入依赖:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>5.5.23</version>
</dependency>