【问题标题】:How to configure querydsl in spring boot 1.4.1?spring boot 1.4.1如何配置querydsl?
【发布时间】:2016-11-07 21:30:54
【问题描述】:

我正在尝试使用 spring-data-jpa 为项目启用 querydsl,但是我遇到了一些编译错误,例如:

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

另外,当我运行 mvn clean install 我得到这个:

Caused by: java.lang.ClassNotFoundException: com.querydsl.core.annotations.QueryEntities

我查看了类路径中的 jar,我可以看到 querydsl-core 4.1.4、querydsl-apt 4.1.4 和 querydsl-jpa 4.1.4。但是项目还是没有为我编译,springboot 1.4.1和querydsl有什么问题吗?

我的 pom.xml 文件中有这个

<dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <scope>provided</scope>
</dependency>

和插件

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

我是不是做错了什么?

--- 更新 ---

我从 querydsl 4.1.4 降级到 4.1.3 并且至少正在编译项目。现在,我可以开始一些测试,我将发布我的发现。

我认为问题仍然悬而未决,因为默认情况下 spring boot 1.4.1 带有 querydsl 4.1.4 版本。

【问题讨论】:

  • 您是否在构建 > 插件或构建 > 插件管理 > 插件中添加了上面的插件。您需要将插件放在 build > plugin

标签: java spring spring-boot spring-data querydsl


【解决方案1】:

将依赖项放入插件中。

<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-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</plugin>

【讨论】:

  • 同样的错误,这对我来说很奇怪,因为我看到核心有 eclipse 正在寻找的类,但由于某种原因没有选择类
  • 运行 eclipse:eclipse 更新 eclipse 项目类路径
  • 还是不行。当我运行 eclipse:eclipse 我得到“Caused by: java.lang.ClassNotFoundException: com.querydsl.core.annotations.QueryEntities”。
  • 你试过 eclipse:eclipse 在 apt-maven-plugin 内部或外部使用 querydsl 依赖项?
猜你喜欢
  • 2021-06-10
  • 2014-05-11
  • 2017-03-24
  • 1970-01-01
  • 1970-01-01
  • 2018-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多