2016-08-23 62 views
0

上,我发现这个问题http://stackoverflow.com/questions/38129930/jackson-partial-working-cannot-return-listobject-or-collectionobject对我很感兴趣,找出解决的答案:杰克逊问题Spring.MVC WildFly服务器

11:28:26,333 ERROR [io.undertow.request] (default task-11) UT005023: Exception handling request to /Spring4MVCAngularJSExample/user/: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectWriter.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectWriter; at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:978) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE]> at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] ...

在我的情况与当我使用Spring的REST API发生WildFly(8.x)服务器上的WAR,但Tomcat(8.5)服务器上的WAR相同。 我仍然试图找到一个解决方案,以使它也可以在WildFly服务器上工作。

请注意,我按照教程spring-mvc-4-angularjs-example,但最初通过Eclipse安装了WildFly(8.x)服务器。

我还修改了的pom.xml依赖关系遵循希望能解决杰克逊的依赖问题:

<properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <springframework.version>4.3.1.RELEASE</springframework.version> 
     <jackson.version>2.7.5</jackson.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${springframework.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.fasterxml.jackson.core</groupId> 
        <artifactId>jackson-core</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.fasterxml.jackson.core</groupId> 
        <artifactId>jackson-annotations</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.fasterxml.jackson.core</groupId> 
        <artifactId>jackson-databind</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
      <version>${jackson.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
    </dependencies> 

如果任何人有一个想法,我洗耳恭听。

+0

仔细看看[link](https://mvnrepository.com/artifact/org.springframework/spring-webmvc/4.3.1.RELEASE)我发现_springframework.version_和_jackson.version_。 **将jackson.version更改为_pom.xml_中的2.8.1解决了问题** – Ceddaerrix

+0

实际上,更正版本并未解决问题。在测试假定的修复程序时,我的Tomcat服务器仍处于打开状态,并且在WAR安装在WildFly上时,Angular服务指向了Tomcat端口。这意味着前端在WildFly上,并在Tomcat上调用后端。 – Ceddaerrix

回答

0

你应该做的一件事wildfly服务器里面去

\ wildfly-8.2.0.Final \模块\ SYSTEM \层\基地\ COM \ fasterxml \杰克逊\核心 然后进屋检查你的罐子版本对于所有核心库,它应该是2.8或更高。 杰克逊的注解-2.8.0.jar 杰克逊核心2.8.3.jar 杰克逊 - 数据绑定-2.8.3.jar

和更改与最新版本的名称module.xml内的所有jar文件版本映射像这样