警告: Exception encountered during context initialization - cancelling refresh attempt: 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
错误原因:缺少servlet-api的依赖包
解决办法:
第一种:直接在pom文件中引入dependency
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>5.5.23</version>
</dependency>
第二种:引入本地tomcat中的servlet-api.jar(以Intellij IDEA为例)
打开 File / Project Structure
注:servlet-api.jar在本地tomcat的lib下面