Christoff Erasmus
Christoff Erasmus

Reputation: 975

Q-Types not generated in Eclipse maven project (QueryDSL & JPA)

Please help my Q-Types are not generating

I am following the baeldung guide:

https://www.baeldung.com/rest-api-search-language-spring-data-querydsl

enter image description here

Multiple markers at this line

  • The type com.querydsl.core.types.Predicate cannot be resolved. It is indirectly referenced from required .class files
  • The type com.querydsl.core.types.OrderSpecifier cannot be resolved. It is indirectly referenced from required . class files

It appears that maven is not able to find the required apt-maven-plugin plugin enter image description here

Plugin could not be resolved. Ensure the plugin's groupId, artifactId and version are present. Additional information: Plugin com.mysema.maven:apt-maven-plugin:1.1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.mysema.maven:apt-maven-plugin:jar:1.1.3

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.3.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>mygroupid</groupId>
<artifactId>mygroupid-artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Testing QueryDSL with JPA</name>
<description>Testing QueryDSL with JPA</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
        <groupId>net.sf.jt400</groupId>
        <artifactId>jt400</artifactId>
        <version>10.4</version>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-ui</artifactId>
        <version>1.2.32</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>

</build>

Running command

mvnw generate-sources

Error Message:

enter image description here

[INFO] --- apt-maven-plugin:1.1.3:process (default) @ partner-management-services --- error: Annotation processor 'com.mysema.query.apt.jpa.JPAAnnotationProcessor' not found 1 error

Upvotes: 0

Views: 1645

Answers (1)

vp131
vp131

Reputation: 97

Try using querydsl-apt.

Dependencies:

    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>4.2.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.querydsl/querydsl-apt -->
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>4.2.1</version>
    </dependency>

Plugin:

       <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>

            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources</outputDirectory>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Similar question has been asked here and got an answer too.

Upvotes: 0

Related Questions