The right set of dependencies to use the Jackson cartographer

I am new to Jackson and I wrote code for practice. I found out that a new version of the Jackson library can be found in Fasterxml: Jackson , so I added the following dependencies to my maven pom file:

<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.2.2</version> </dependency> 

I expected that I could use ObjectMapper directly, however, having spent a lot of time, I found out that to use ObjectMapper I need to add the old libraries below:

 <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-asl</artifactId> <version>1.9.2</version> </dependency> 

I am a bit confused. Can someone please tell me why?

+45
java json jackson
Aug 25 '13 at 13:25
source share
5 answers
 <properties> <!-- Use the latest version whenever possible. --> <jackson.version>2.4.4</jackson.version> </properties> <dependencies> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency> </dependencies> 

you have ObjectMapper (from the Jackson Databind package). if so, you can do:

 JsonFactory factory = objectMapper.getFactory(); 

Source: https://github.com/FasterXML/jackson-core

So, the 3 "quickxml" dependencies that you already have in u'r pom are enough for ObjectMapper, since it includes a jackson-databind.

+31
Feb 24 '15 at 13:25
source share

No, you can just use com.fasterxml.jackson.databind.ObjectMapper . Most likely, you forgot to fix your import stats, delete all links to the code, and you are gold.

+5
07 Oct '14 at 14:41
source share

Jackson 2.x package names changed to com.fasterxml 1 from org.codehaus 2 . Therefore, if you just need ObjectMapper, I think Jackson 1.X can satisfy your needs.

+2
Aug 01 '14 at 2:02
source share

Besides fixing the import, make a new maven clean compile -U . Note the -U option, which introduces new dependencies that the editor sometimes has to deal with. Let the compilation fail due to non-imported classes, but at least you have the opportunity to import them after the maven command.

Just doing Maven -> Reimport from Intellij didn't help me.

+1
Jul 14 '17 at 22:01
source share

I spent several hours on this.

Even if I had the correct dependency, the problem was fixed only after I deleted the com.fasterxml.jackson folder in the .m2 repository under C: \ Users \ username.m2 and updated the project

0
Nov 05 '16 at 12:04
source share



All Articles