Maven Integration with Query DSL

痞子三分冷 提交于 2019-12-22 16:58:46

问题


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?


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/35850436/maven-integration-with-query-dsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!