Reputation: 2284
I have a Spring Boot application that I am developing using the STS on Eclipse. I am attempting to incorporate into this application the Jackson libraries using Maven.
The dependencies in my project, as identified in my POM file, are below:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
I have been attempting to compile the code using
mvnw clean package
but I am getting compilation failures caused by the following:
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
... 62 common frames omitted
The library with that class is already declared in the POM file!
I am clearly missing something here. How do I get the compiler to include the Jackson jars intothe compilation sp that mvnw stops failing?
Upvotes: 0
Views: 566
Reputation: 8031
If you look into the following url, jackson databind has dependencies on jackson core and jackson annotations. So there is no need to mention them. It will internally use the dependency. As Denium Sir said, remove the dependencies, use only jackson databind for normal case, in case of Spring boot application simply use BOM (Build of Material), there is no need to mention these dependencies.
https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.7.5
Upvotes: 4