开发者

Is there any way to override or update Jersey's Jackson version?

We're trying to use Jackson 1.5 to take advantage of some of the polymorphic handling it offers, but it appears that Jersey brings along it's own outda开发者_JAVA技巧ted version of Jackson (1.1.1). When testing Jersey serialized JSON, we get different results than when we serialize by hand in unit tests.

{
  "id": "40",
  "ticketProps": [{
    "id": "28",
    "field": {
      "id": "28",
      "name": "WXYZ",
      "strict": "false",
      "valueType": "STRING"
    },
    "value": "W"
  }, {
    "id": "29",
    "field": {
      "id": "29",
      "name": "SEAT",
      "strict": "false",
      "valueType": "STRING"
    },
    "value": "4A"
  }]
}

{
  "id": "40",
  "ticketProps": [{
    "id": "28",
    "field": {}
  }, {
    "id": "29",
    "field": {}
  }],
  "name": null
}

Unfortunately using Jackson 1.1.1 is not an option. Is there any way to get Jersey to use Jackson 1.5? Was thinking of trying to set it in the Jersey Config class or something...


If the maven POM for Jersey does not allow you to separate the Jackson dependency from the Jersey dependency, then you could get hold of the individual JARs manually, swapping out the Jackson 1.5.x JAR(s) for the 1.1.x one.

Note that there's no guarantee that Jersey will work with the newer Jackson version. Jackson's API changed quite a lot around the 1.1 releases.


You didn't give much details (especially about your runtime environment) so I'll just cover the maven part of the question: declare the version 1.5 of Jackson under the dependencyManagement section to force the convergence in other dependencies having jackson as dependency.

Wheter this will work at runtime is left as an exercise for the reader :)

For the record, here is what we can read in the V3.1JerseyOnePager:

Jersey is currently using Jackson 1.1 in GlassFish 3.0. The version will be upgraded in 3.1 to the latest stable version (currently 1.5.2).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜