I have created a Maven project on Eclipse and have added the following dependency on the pom.xml file:
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-xml-databind</artifactId>
<version>0.6.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
Then I use the following code to check if the dependency can be compiled:
import com.fasterxml.jackson.databind.ObjectMapper;
public class App
{
public static void main(String[] args) {
ObjectMapper mapper = new ObjectMapper();
}
}
Although Eclipse does not show any error, when I compile it using the following commands:
$ javac -sourcepath src src\main\java\App.java
I recieve the following 3 errors:
src\main\java\App.java:6: error: package com.fasterxml.jackson.databind does not exist
import com.fasterxml.jackson.databind.ObjectMapper;
^
src\main\java\App.java:16: error: cannot find symbol
ObjectMapper mapper = new ObjectMapper();
^
symbol: class ObjectMapper
location: class App
src\main\java\App.java:16: error: cannot find symbol
ObjectMapper mapper = new ObjectMapper();
^
symbol: class ObjectMapper
location: class App
3 errors
Keep in mind that the corresponding JAR files to the dependancies are installed into the maven repository on the computer
javac. So It expects those jar files to be on classpath not in mvn