简体   繁体   English

Spring Boot 上的 QueryDSL 问题

[英]Issue with QueryDSL on Spring Boot

I set up my project exactly as depicted on http://zetcode.com/springboot/querydsl/ .我完全按照http://zetcode.com/springboot/querydsl/ 上的描述设置了我的项目。 The QCity class is automatically generated. QCity 类是自动生成的。

Here's the method of the @SpringBootApplication annotated class:下面是@SpringBootApplication 注解类的方法:

@Override
    public void run(String... args) throws Exception {

        QCity qCity = QCity.city;

        JPAQuery query = new JPAQuery(entityManager);

        query.from(qCity).where(qCity.name.eq("Bratislava")).distinct();
        var c1 = query.fetch();

        logger.info("{}", c1);

}

I performed the maven clean and then install我执行了 maven clean 然后安装

However I got this error log while trying to execute :但是我在尝试执行时收到了这个错误日志:

java.lang.Error: Unresolved compilation problems: 
    QCity cannot be resolved to a type
    QCity cannot be resolved to a variable
    var cannot be resolved to a type

    at grupo.artefatoX2.ArtefatoX2Application.run(ArtefatoX2Application.java:37) ~[classes/:na]

which points precisely to this line QCity qCity = QCity.city;正好指向这条线 QCity qCity = QCity.city;

The log was shortened.日志被缩短了。

What went wrong ??什么地方出了错 ??

You need to generate sources :您需要生成源:

mvn generate-sources

Or include the plugin mentioned here: QueryDsl - How to create Q classes with maven?或者包括这里提到的插件: QueryDsl - How to create Q classes with maven? in your pom as below and run mvn clean install.在您的 pom 中,如下所示并运行 mvn clean install。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM