Spring Tool Suite - NoClassDefFoundError MappingJackson2XmlHttpMessageConverter

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I am new to Spring and I am starting to learn it from his website. Understanding Java is not difficult to me, but I have trouble with the environment. I followed this guide for using Spring Boot for creating a new project and everything went great https://spring.io/guides/gs/spring-boot/

Now I would like to run this project from the Spring Tool Suite but I get this error when I try to run the same code on Pivotal or Tomcat server.

Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConverters]: >Factory method 'messageConverters' threw exception; nested exception is java.lang.NoClassDefFoundError:org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter

Any help from Spring developers for fixing my workflow?

回答1:

When you try to run the project via a server, first build it using maven so that all the dependencies are downloaded. This helps to download MappingJackson2XmlHttpMessageConverter class also. After building it deploy the war you create into the server.



回答2:

This class is added to spring from 4.1. You have to add

compile('org.springframework:spring-web:4.1.4.RELEASE') 

for gradle, or

<dependency>     <groupId>org.springframework</groupId>     <artifactId>spring-web</artifactId>     <version>4.1.4.RELEASE</version> </dependency> 

for maven.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!