Maven Integration with Query DSL
Asked Answered
C

2

4

I am trying to integrate an existing project in maven with query dsl I have added the dependencies as below `

<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>2.5.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-jpa</artifactId>
    <version>2.5.0</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.6.1</version>
</dependency>`

and also configured the above as per the documentation and did Maven Clean it is build successfully but It fails when I do Maven Install error above

<build>
    <pluginManagement>
        <plugins>
           <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>maven-apt-plugin</artifactId>
                <version>1.0.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>
    </pluginManagement>
</build>

When I do Maven Install - BUILD FAILURE and cant resolve the dependency for query DSL isn't maven supposed to do this on its own.

[WARNING] The POM for com.mysema.querydsl:querydsl-apt:jar:2.5.0 is missing, no dependency information available
[WARNING] The POM for com.mysema.querydsl:querydsl-jpa:jar:2.5.0 is missing, no dependency information available
[INFO] BUILD FAILURE

what am I missing?

Caspian answered 7/3, 2016 at 17:46 Comment(3)
You might want to try newer versions. 2.x is very old and isn't maintained. Also, maven-apt-plugin is now apt-maven-plugin.Maihem
@Maihem yeah I didnt notice that thanks Do you have any idea how to resolve the dependency issue I am having tho?Caspian
I created a sample project, copied in the configuration you posted and removed the <pluginManagement> tags and the q classes were generated. I did have to add <dependency><groupId>org.hibernate.javax.persistence</groupId><artifactId>hibernate-jpa-2.1-api</artifactId><version>1.0.0.Final</version></dependency>> so I could annotate my entity with @Entity.Maihem
U
4

the next code snippet seems to be working for me. Can you try it this way?

<dependencies>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-core</artifactId>
        <version>3.6.3</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>3.6.3</version>
    </dependency>    
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>3.6.3</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <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>${project.build.directory}/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Maybe you're missing just the querydsl-core dependency or the apt maven plugin is misspelled.

If the module is still not found try to temporarely rename the ~/.m2/settings.xml file. Some settings, repository proxies may cause problems.

Ur answered 7/3, 2016 at 18:4 Comment(4)
Yes I was missing that but didn't resolve anything except adding one more warning on Missing dependency from the my POM.xml file. Do you have any idea why I am not able to download the dependency on Maven Install? Help :)Caspian
Do you maybe have a settings.xml file in ~/.m2?Ur
yes I do have settings.xml file which only holds proxy and mirror idCaspian
Try to rename the file temporarily and run mvn install again.Ur
E
1

as github:querydsl/querydsl say,I use com.querydsl(last update 2018,version 4.2.1) but not /com.mysema.querydsl (last update 2010):

    <properties>
    <querydsl.version>4.2.1</querydsl.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-core</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <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.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>4.1.2</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
Eugenie answered 2/11, 2018 at 8:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.