I set up my project exactly as depicted on http://zetcode.com/springboot/querydsl/ . The QCity class is automatically generated.
Here's the method of the @SpringBootApplication annotated class:
@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
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;
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? in your pom as below and run mvn clean install.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.