简体   繁体   中英

hibernate jpa metamodel generator: "Problem with Filer: Attempt to recreate a file for type"

I need to generate JPA metamodel types but I can not get rid of the mentioned filer problem. I'm using maven and have simply added this dependency in my pom.xml which triggers the annotation processor automatically:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-jpamodelgen-jakarta</artifactId>
    <version>5.5.7.Final</version>
    <scope>provided</scope>
</dependency>

I made some further investigations regarding the filer problem and here is what I found out (if you are in a hurry to find out about the solution of the filer problem just jump to the bottom of this answer).

Using the following dependencies in maven triggers automatic generation of jpa static metamodel when running "mvn compile":

    <dependencies>

        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen-jakarta</artifactId>
            <scope>provided</scope>
            <version>5.6.12.Final</version>
        </dependency>

    </dependencies>

BTW: There's really nothing else to be done for jpa static metamodel generation.

But make sure to look at the right location for the generated code. You will find it under target/generated-sources/annotations .

The filer problem occurs, if you have (a copy of) jpa static metamodel source code in your "usual" source code directory, eg src/main/java . You can solve this if you delete the files in the source code directory.

If your IDE now complains about unresolvable types named *_, just add target/generated-sources/annotations as source code folder in the IDE's build path.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM