2016-08-23 59 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文件版本映射像這樣