运行spring应用程序并使用RestTemplate
时出现此错误
但是在运行junit测试时我发现没问题
在我的测试中,我生成了这个json。
[
{
"idProcesoElectoral": 9,
"idSolicitud": 591,
"folioSiilnere": "E1009000591",
"idEstatusSolicitud": 2,
"fechaEstatus": "25/10/17 13:13:51"
}
]
错误:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectWriter.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectWriter;
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:264)
at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:100)
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:830)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:617)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:128)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:380)
我已经读到它可能是某个地方的版本冲突,但找不到罪魁祸首。
以下是杰克逊图书馆
./siilnere-web/target/siilnere-web-6.4.1.0.5/WEB-INF/lib/jackson-datatype-jsr310-2.2.3-beta5.jar
./siilnere-web/target/siilnere-web-6.4.1.0.5/WEB-INF/lib/jackson-annotations-2.8.9.jar
./siilnere-web/target/siilnere-web-6.4.1.0.5/WEB-INF/lib/jackson-databind-2.8.9.jar
./siilnere-web/target/siilnere-web-6.4.1.0.5/WEB-INF/lib/jackson-core-2.8.9.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-datatype-jsr310-2.2.3-beta5.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-core-asl-1.9.13.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-mapper-asl-1.9.13.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-annotations-2.8.9.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-databind-2.8.9.jar
./siilnere-ear/target/siilnere-ear-6.4.1.0.5/APP-INF/lib/jackson-core-2.8.9.jar
感谢任何帮助。
三江源
编辑: 我读了一个建议暂时使用java参数-verbose:class来尝试调试它。
我抓住weblogic的输出并得到了这个 并找到这样的语句(虽然我没有找到任何类似引用类ObjectWriter):
Loaded com.fasterxml.jackson.databind.deser.std.StringDeserializer from file:/opt/Oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/com.fasterxml.jackson.core.jackson-databind.jar
但是我在weblogic.xml中有这个:
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>com.fasterxml</package-name>
</prefer-application-packages>
</container-descriptor>