Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data Querydsl in eclipse not generating query type classes

I don't see query dsl classes generated in eclipse added below dependency and plugin in the pom.xml. Can some please review below change required for query-dsl integration in spring boot?

<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>${querydsl.version}</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-jpa</artifactId>
    <version>${querydsl.version}</version>
</dependency>

<!--Plugin for query-dsl -->
    <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>

`

like image 741
Harshal Avatar asked Nov 24 '25 10:11

Harshal


2 Answers

In eclipse, sometimes you have to refresh your project multiple times to see the generated-sources. If not try to generate the files by

right click on your project -> run as -> maven generate sources.
like image 173
Patrick Avatar answered Nov 27 '25 22:11

Patrick


This problem is due to annotation processing of M2E. New Eclipse versions contain an experimental feature, which delegates annotation processing to maven plugins and thus behaves the same as using mvn from the command line.

To enable the feature:

  1. rightclick a project and select properties
  2. in the properties navigate to Maven -> Annotation Processing
  3. to enable this option for the whole workspace and not just for this specific module select Configure Workspace Settingsenter image description here
  4. Select Experimental: Delegate annotation processing to maven plugins (for maven processor only).enter image description here
  5. Click Apply.

This way Eclipse processes annotations with the plugins defined in the pom.xml. Resources are now generated when building the project and also found as dependency. No need to build the project manually with maven.

like image 34
elpair Avatar answered Nov 27 '25 22:11

elpair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!