javamavenjavaparser

Include JavaParserJsonSerializer in JavaParser Maven Project?


I'm attempting to include the JavaParserJsonSerializer class in my Java program using the JavaParser library. I'm using the latest JavaParser v3.25.9, and the IntelliJ IDE v2023.2.5.

I wanted to compile one of the basic JavaParserJsonSerializer examples. However, while I am able to import the core JavaParser classes such as CompilationUnit (located in com.github.javaparser.ast), I am not able to import any of the classes in the com.github.javaparser.serialization package (including JavaParserJsonSerializer) in any of my project files. Instead I'm simply prompted with:

Cannot resolve symbol 'serialization'

I am including the JavaParser library in my Maven project via the following dependency in the project's pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.github.javaparser</groupId>
        <artifactId>javaparser-core</artifactId>
        <version>3.25.9</version>
    </dependency>
</dependencies>

I am not very experienced with Maven's methods of handling dependencies, but I initially assumed that I would need to add the com.github.javaparser.serialization dependency in addition to the core com.github.javaparser dependency. However, that does not appear to be the issue. Attempting to change the dependencies like such:

<dependencies>
    <dependency>
        <groupId>com.github.javaparser</groupId>
        <artifactId>javaparser-core</artifactId>
        <version>3.25.9</version>
    </dependency>
    <dependency>
        <groupId>com.github.javaparser.serialization</groupId>
        <artifactId>javaparser-core-serialization</artifactId>
        <version>3.25.9</version>
    </dependency>
</dependencies>

Results in:

Dependency 'com.github.javaparser.serialization:javaparser-core-serialization:3.25.9' not found

What is the proper way to import the JavaParser classes from the com.github.javaparser.serialization package, such as JavaParserJsonSerializer?

Thanks for reading my post, any guidance is appreciated.


Solution

  • ur maven groupId using com.github.javaparser see Maven and javaparser