java - Spring Boot 上的 QueryDSL 问题
问题描述
我完全按照http://zetcode.com/springboot/querydsl/上的描述设置了我的项目。QCity 类是自动生成的。
这是@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);
}
我执行了 maven clean 然后安装
但是我在尝试执行时收到了这个错误日志:
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]
正好指向这条线 QCity qCity = QCity.city;
日志被缩短了。
什么地方出了错 ??
解决方案
您需要生成来源:
mvn generate-sources
或者包括这里提到的插件:QueryDsl - How to create Q classes with maven? 在您的 pom 中如下所示并运行 mvn clean install。
推荐阅读
- arrays - 创建这种类型的数组
- actions-on-google - 在 Google 助理上找不到已部署的 Google Action(生产版本)
- python - 如何在 AWS EC2 上连接 Google sheet API
- c# - .NET 5 RC1 API 控制器构造函数问题
- excel - vba应付变量模块
- java - 我们应该在代码中包含测试语句吗?
- java - 如何在java中的接口上注释?
- amazon-web-services - 如何限制 AWS Application Load Balancer 中的文件上传大小?
- c# - Word VSTO 中的插件选项页面在哪里?
- java - 使用 proguard 进行批量混淆