Skip to content

querydsl: java.lang.NoSuchFieldError: TREATED_PATH

springboot version is 2.51, java vsersion 1.8 it will crash in selectFrom(), erro info: java.lang.NoSuchFieldError: TREATED_PATH

how to resolve it,i cant find a way in web

there is my code

class Demo4ApplicationTests {
    private BmsPostRepository bm;
    private JPAQueryFactory queryFactory;
    void contextLoads() {
        var tab="hot";
        var page = PageRequest.of(pageNo, pageSize);
        var t = QBmsPost.bmsPost;
        var u = QUmsUser.umsUser;
        var now = new Date();
        var tomorrow = DateUtils.addDays(now, 1);
        var query = queryFactory
        if (tab.equals("hot")) query = query.where(;
        var re = (!tab.equals("hot")) ?
                query.orderBy(t.createTime.desc()) :
                query.orderBy(t.view.desc(), t.createTime.desc());
        var er =re.fetch();


there is dependency


java.lang.NoSuchFieldError: TREATED_PATH

    at com.querydsl.jpa.JPQLTemplates.<init>(
    at com.querydsl.jpa.JPQLTemplates.<init>(
    at com.querydsl.jpa.JPQLTemplates.<clinit>(
    at com.querydsl.jpa.impl.JPAProvider.<clinit>(
    at com.querydsl.jpa.impl.JPAQuery.<init>(
    at com.querydsl.jpa.impl.JPAQueryFactory.query(
    at com.querydsl.jpa.impl.JPAQueryFactory.selectFrom(
    at com.example.demo.Demo4ApplicationTests.contextLoads(



You have mixed versions of querydsl. I guess you are having querydsl-core version 4.4.x while your querydsl-jpa is of version 5.0.0.M1. (this is probably caused by a spring-boot starter library.)

Anyhow, this can easily fixed by explicitely adding the correct version of querydsl-core as dependency.