我正在使用Spring Boot和带有Mongo DB的Spring Data进行Web项目。 我有一个名为Employee的模型类,带有带下划线的变量名。我编写了一种使用group by从DB获取字段计数的方法,但是当我执行应用程序时,我得到了错误 org.springframework.data.mapping.PropertyReferenceException:找不到类型为Employee的属性人!
TypedAggregation<Employee> studentAggregation =
Aggregation.newAggregation(Employee.class, Aggregation.group("customer","person_Type","project_Location").count().as("total"),Aggregation.project("customer","person_Type","project_Location",
"total"),Aggregation.sort(Direction.ASC,"customer"
,"person_Type","project_Location"));
AggregationResults<Employee> results = mongoTemplate.aggregate(studentAggregation, Employee.class);
员工数据模型:
@Document(collection = "employee")
public class Employee {
@Id
public long emp_id;
private String work_Geography;
private String work_Country;
private String work_Location;
private String customer;
private String project_Location;
private String person_Type;
}
答案 0 :(得分:0)
这是处理带下划线的属性的错误(DATAMONGO-2339),已在 Lovelace SR 11 又称为 Spring Data MongoDB 2.1.11 中解决。请升级。