无法初始化类com.mysema.query.jpa.HQLTemplates

时间:2018-02-09 14:06:09

标签: java spring querydsl

我有一个带有REST API的Spring启动应用程序,我试图通过查询参数使结果集可过滤。看了this article后,我认为QueryDSL可以很好地满足这个要求。

我目前遇到的问题是,在运行时似乎无法访问类...此外,我已经在IntelliJ中明确地将jar添加到类路径

错误

java.lang.NoClassDefFoundError: Could not initialize class com.mysema.query.jpa.HQLTemplates
    at org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:83) ~[spring-data-jpa-1.9.2.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:98) ~[spring-data-jpa-1.9.2.RELEASE.jar:na]

依赖关系在pom中,因为我使用spring-boot-maven-plugin它们应该捆绑到工件中。

POM

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>${querydsl.version}</version>
    </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/apt</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>${querydsl.version}</version>
                </dependency>
            </dependencies>
        </plugin>

版本

<properties>
    <spring.boot.version>1.3.2.RELEASE</spring.boot.version>
    <querydsl.version>3.7.4</querydsl.version>
</properties>

0 个答案:

没有答案