mongotemplate中的属性引用异常

lnlaulya  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(218)

我有下面的方法。必须返回发布年份>2013的公交车。

public List<Bus> greater(){
    return mongoTemplate.find(new Query(Criteria.where("year_of_release").gt(2013)),Bus.class);
}

此代码引发异常

org.springframework.data.mapping.PropertyReferenceException: No property year found for type Bus!

公共汽车等级

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Document
public class Bus {
    @Id
    private String id;
    private String manufecturer;
    private String model;
    private String licence_plate_number;
    private String vin_code;
    private int bus_class;
    private int number_of_seats;
    private int year_of_release;
    private int mileage_km;
}

mongodb总线示例文档

{
    "_id": {
        "$oid": "602942ea5c418262b0b364b9"
    },
    "manufecturer": "MAN",
    "model": "12E",
    "licence_plate_number": "CE0001AA",
    "vin_code": "1HVBBAAM1YH314841",
    "bus_class": 1,
    "number_of_seats": 70,
    "year_of_release": 2012,
    "mileage_km": 1000000
}

我看到类似的问题,但没有帮助我。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题