SpringMVC 发生异常 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
运行时:
Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0'
defined in ServletContext resource [/WEB-INF/spring-mvc.xml]:
Cannot create inner bean 'util:list#19a454b' of type [org.springframework.beans.factory.config.ListFactoryBean]
while setting bean property 'messageConverters';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'util:list#19a454b':
Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
原因:缺少夹包
解决:在 pom.xml 文件中添加如下:
<!-- jackson start -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.1.0</version>
</dependency>
<!-- jackson end -->