Jersey Jackson and codehaus vs. fasterxml

时间秒杀一切 提交于 2019-12-18 10:23:06

问题


I'm using Jersey 1.17.1 with Jackson 2.2.1.

It seems like Jackson switched packages from org.codehaus to com.fasterxml. I have all my code configured properly and using the latest jackson. However, it seems like Jersey is still pulling in org.codehaus.jackson. Is there any way to mitigate this or should I stick with the codehaus packages until jersey is upgraded to use the fasterxml packages?


回答1:


The older Jackson libraries are being pulled in as dependencies of the jersey-json artifact. When

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-json</artifactId>
    <version>1.17</version>
</dependency>

is included in your POM you will automatically get versions of the org.codehaus.jackson libraries included in your project. Unfortunately, jersey-json itself has link time dependencies on the Jackson classes, so you can't simply use exclusions. What you want do to instead is omit it entirely. It's really a kind of wrapper library around a bunch of JSON libraries that you do not necessarily need. Once removed, you can add dependencies for the Jackson 2.2.1 libraries and JAX-RS provider:

<dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-json-provider</artifactId>
    <version>2.2.1</version>
</dependency>

Note that with jersey-json removed you no longer have a Stax2, Jettison, or JAXB provider. If you need those then you will have to locate and add dependencies for them manually.



来源:https://stackoverflow.com/questions/16876482/jersey-jackson-and-codehaus-vs-fasterxml

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