4

我正在尝试将 maven 中的现有项目与查询 dsl 集成我添加了如下依赖项`

<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>`

并且还根据文档配置了上述内容并且 Maven Clean 构建成功但是当我执行上面的 Maven 安装错误时它失败了

<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>

当我执行 Maven 安装 - BUILD FAILURE 并且无法解决查询 DSL 的依赖关系时,maven 不应该自行执行此操作。

[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

我错过了什么?

4

2 回答 2

4

下一个代码片段似乎对我有用。你可以这样试试吗?

<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>

也许您只是缺少querydsl-core依赖项,或者 apt maven 插件拼写错误。

如果仍未找到该模块,请尝试暂时重命名该~/.m2/settings.xml文件。某些设置、存储库代理可能会导致问题。

于 2016-03-07T18:04:30.860 回答
1

正如github:querydsl/querydsl所说,我使用com.querydsl(最后一次更新 2018,版本 4.2.1)而不是/com.mysema.querydsl(最后一次更新 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>
于 2018-11-02T08:41:00.317 回答