Spring的啓動傑克遜錯誤我有一個非常奇怪的問題,使用Maven的Spring-boot 1.5.2構建war包,它與Jackson依賴關係有錯誤,僅在Ubuntu 16.04上,因爲我使用的是另一個Centos 7,並且沒有將應用程序打開爲war或jar文件的問題。與Maven的war文件,但沒有jar文件與com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
與Maven構建到JAR或戰爭結束後,我可以運行內置包
javar -jar target/project.war (or project.jar)
和嵌入式Tomcat將啓動。也可以將war包部署到Centos 7的webapps目錄中的外部Tomcat。對於Ubuntu 16.04,我只能運行Tomcat嵌入的.jar文件,而不能使用Tomcat Embedded/External運行war文件。
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 26 more
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:564)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:474)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:588)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:57)
at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:61)
at org.springframework.web.filter.HttpPutFormContentFilter.<init>(HttpPutFormContentFilter.java:63)
at org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter.<init>(OrderedHttpPutFormContentFilter.java:29)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.httpPutFormContentFilter(WebMvcAutoConfiguration.java:142)
這裏是POM文件https://pastebin.com/13MwTm89我只能從傑克遜再添依賴於XML反序列化到對象。
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.8.7</version>
</dependency>
這裏是傑克遜
mvn dependency:tree | grep 'jackson'
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.8.7:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile
[INFO] | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.8.7:compile
爲什麼使用'jackson-annotations:jar:2.8.0',其餘的都是2.8.7? – StanislavL
這不是從我這裏,它是從Spring引導依賴父。 –
嘗試降級您的版本。或者排除彈簧的依賴關係,並添加正確版本 – StanislavL