javamavenjpaintellij-ideadatanucleus

IntelliJ IDE Cannot Find javax.annotation.processing.Generated Symbol While mvn test Works Correctly


I am having a problem with my project configuration and running the program and unit test. When running with mvn test the JUnit test executes propertly, but when executing from within the IntelliJ IDE, it throws:

## JPS Errors Summary
java:ERROR:cannot find symbol
  symbol:   class Generated
  location: package javax.annotation.processing; file: /home/api/target/generated-sources/annotations/org/example/core/user/model/User_.java at (3:35)
java:ERROR:cannot find symbol
  symbol: class Generated; file: /home/api/target/generated-sources/annotations/org/example/core/user/model/User_.java at (6:2)

Here are the POM dependencies on Datanucleus:

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>javax.persistence-api</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-core</artifactId>
    <version>5.2.11</version>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-rdbms</artifactId>
    <version>5.2.11</version>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-api-jpa</artifactId>
    <version>5.2.8</version>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-jpa-query</artifactId>
    <version>5.0.5</version>
</dependency>
<!-- Plugins -->
<plugin>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-maven-plugin</artifactId>
    <version>5.2.1</version>
    <configuration>
        <api>JPA</api>
        <persistenceUnitName>test-pu</persistenceUnitName>
        <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
        <verbose>true</verbose>
    </configuration>
    <executions>
        <execution>
            <phase>process-classes</phase>
            <goals>
                <goal>enhance</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
        <annotationProcessorPaths>
            <path>
                <groupId>javax.annotation</groupId>
                <artifactId>javax.annotation-api</artifactId>
                <version>1.3.2</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin> 

Solution

  • The solution is to downgrade the JVM from 11 to 8. Then running mvn datanucleus:enhance first before running the IDE build (e.g. run or test). For maven, the enhancing runs automatically.