Issue
I've created a JavaFX project using IntelliJ, together with Maven. I'm trying to test some system that adds items into an XML file and then parses it and shows me all the items added to the file.
I want to use FasterXML/Jackson for parsing the files. In my pom.xml
, I've added the following dependency:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.13.2</version>
</dependency>
(...) and I also loaded the Maven changes from the button provided by IntellJ. I also pressed the Reload all Maven Changes button. The "Dependencies" folder seems to be all okay. I've received no errors or complaints:
However, when I'm trying to import some Jackson-related class, such as ObjectMapper
, like this:
import com.fasterxml.jackson.databind.ObjectMapper;
(...) I receive such an error:
Package 'com.fasterxml.jackson.databind' is declared in module 'com.fasterxml.jackson.databind', but module 'com.example.demo1' does not read it
.
This is my project structure:
What could be the problem?
Solution
I've managed to fix my problem. In my module-info.java
I needed to add the following line of code:
requires com.fasterxml.jackson.databind;
Found something similar in an answer provided to a question on Stack (How to solve package is declared in module, but module does not read it?), although the user who answered said you need to also open the module. Opening the module, though, would result in some other error, but just mentioning it as a requirement should be enough.
Answered By - Mario MateaČ™
Answer Checked By - Gilberto Lyons (JavaFixing Admin)