JPA:QUERY DSL错误:java.lang.NoSuchFieldError:LIKE_IC

哈沙尔

运行查询dsl时出现以下错误。

    018-05-01 13:18:38.517 DEBUG 372 --- [nio-8080-exec-1] o.s.b.c.web.OrderedRequestContextFilter  : Cleared thread-bound request context: [email protected]
    2018-05-01 13:18:38.520 ERROR 372 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/boot] threw exception [Handler processing failed; nested exception is java.lang.NoSuchFieldError: LIKE_IC] with root cause

    java.lang.NoSuchFieldError: LIKE_IC
        at com.mysema.query.jpa.JPQLTemplates.<clinit>(JPQLTemplates.java:38) ~[querydsl-jpa-3.7.4.jar:na]

当我再次遇到相同的请求时,我得到了不同的异常:

2018-05-01 13:36:47.839 DEBUG 7964 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Could not complete request

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mysema.query.jpa.HQLTemplates
    at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1305) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:979) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.filter.OncePerRequ

我在下面调用DSL搜索查询的域类

package com.springboot.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

@Entity
@Table(name = "app_user", catalog = "testdb")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class AppUser implements java.io.Serializable {

    Integer id;
    private Rank rank;
    private Trainingstatus trainingstatus;
    private String name;
    private int age;
    private double salary;
    Set<Address> addresses = new HashSet<Address>(0);


    public AppUser(Rank rank, Trainingstatus trainingstatus, String name, int age, double salary,
            Set<Address> addresses) {
        this.rank = rank;
        this.trainingstatus = trainingstatus;
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.addresses = addresses;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)

    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rankId", nullable = false)
    //@JsonManagedReference(value="rank")

    public Rank getRank() {
        return this.rank;
    }

    public void setRank(Rank rank) {
        this.rank = rank;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "trainingStatusId", nullable = false)
    //@JsonManagedReference(value="trainingstatus")
    /*@JsonBackReference
    @JsonIgnore*/
    public Trainingstatus getTrainingstatus() {
        return this.trainingstatus;
    }

    public void setTrainingstatus(Trainingstatus trainingstatus) {
        this.trainingstatus = trainingstatus;
    }

    @Column(name = "name", nullable = false, length = 30)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "age", nullable = false)
    public int getAge() {
        return this.age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Column(name = "salary", nullable = false, precision = 22, scale = 0)
    public double getSalary() {
        return this.salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "appUser" , cascade = CascadeType.ALL )
    public Set<Address> getAddresses() {
        return this.addresses;
    }

    public void setAddresses(Set<Address> addresses) {
        this.addresses = addresses;
    }
}

我的DSL查询

QAppUser qappUser = QAppUser.appUser;
            BooleanExpression rankExp = qappUser.rank.rank.equalsIgnoreCase(user.getRank().getRank());
            BooleanExpression nameExp = qappUser.name.equalsIgnoreCase(user.getName());
            List<AppUser> createdUser = (List<AppUser>) userRepo.findAll(nameExp.and(rankExp));77

Github项目-https ://github.com/harshalpatil2012/Springboot正常的JPA查询在这里工作,而不是query-dsl一个,有些可以在这里帮助我。

哈沙尔

嗨,已引用此页面,并在其正常运行后从项目中删除了查询dsl核心软件包依赖项。

在春季启动中,我们不需要query-dsl核心软件包,这会导致上述错误。

        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-core</artifactId>
            <version>3.6.7</version>
        </dependency>

对于春季启动,下面的依赖关系就足够了。

<dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>3.7.4</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
            <version>3.7.4</version>
        </dependency>

<plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <version>1.1.2</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>src/main/generated/</outputDirectory>
                            <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.mysema.querydsl</groupId>
                        <artifactId>querydsl-apt</artifactId>
                        <version>3.7.4</version>
                    </dependency>
                </dependencies>
            </plugin>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

来自分类Java

Spring JPA @Query与LIKE

来自分类Dev

NullnessChecker错误:java.lang.NoSuchFieldError:释放

来自分类Dev

Spring Data JPA @Query注释的子句错误

来自分类Java

java.lang.NoSuchFieldError:INSTANCE

来自分类Java

java.lang.NoSuchFieldError:默认

来自分类Dev

java.lang.NoSuchFieldError:反思

来自分类Java

“java.lang.NoSuchFieldError的:超级”异常 - 错误的编译器?

来自分类Java

Spring 3.1 entityManagerFactory java.lang.NoSuchFieldError:NULL错误

来自分类Java

春天JPA @Query注释,在SQL地理位置错误

来自分类Dev

更改类后java.lang.NoSuchFieldError

来自分类Dev

ScalaFx MouseEvent:java.lang.NoSuchFieldError:返回

来自分类Java

抖动错误:java.lang.NoSuchFieldError的PREFER_HIGHEST_OR_REMOTE_VERSION_NO_FORCE_STAGING

来自分类Dev

如何解决此错误:java.lang.NoSuchFieldError:UTF_32BE?

来自分类Dev

AWS EMR客户端错误:java.lang.NoSuchFieldError:SIGNING_REGION

来自分类Dev

蜂巢上的Spark错误java.lang.NoSuchFieldError:SPARK_RPC_SERVER_ADDRESS

来自分类Java

SQL错误:1064,SQLState:@Query中的42000-JPA,MySQL,Hibernate

来自分类Dev

使用nativeQuery = true在JPA存储库中执行@Query的ResultSet错误

来自分类Java

春季:java.lang.NoSuchFieldError:IMPORT_BEAN_NAME_GENERATOR

来自分类Java

java.lang.NoSuchFieldError的:ACCEPT_CASE_INSENSITIVE_VALUES

来自分类Dev

使用ScalaTest时出现java.lang.NoSuchFieldError

来自分类Java

线程“主”中的异常java.lang.NoSuchFieldError:TRACE

来自分类Dev

JSON解析器-java.lang.NoSuchFieldError:defaultReader

来自分类Dev

Eclipse无法启动:java.lang.NoSuchFieldError:url

来自分类Dev

Android Gradle Sync在Configure Build阶段失败,错误为java.lang.NoSuchFieldError:JAVA_LETTER_OR_DIGIT

来自分类Dev

无法解决错误:java.lang.NoSuchFieldError:FAIL_ON_SYMBOL_HASH_OVERFLOW- elasticsearch Java客户端api

来自分类Java

java.lang.ClassCastException:[无法将B强制转换为[Ljava.lang.Object; 在使用JPA 2.2 query.getResultStream()。findFirst()时

来自分类Dev

使用@Query休眠jpa投影

来自分类Mysql

在Spring JPA中使用@Query从数据库获取数据时,java.lang.NullPointerException。虽然查询在MySql中返回数据

来自分类Java

线程“主”中的异常java.lang.NoSuchFieldError:JAVA_VENDOR

TOP 榜单

热门标签

归档