Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB+Spring MVC_Mongodb_Spring Mvc - Fatal编程技术网

MongoDB+Spring MVC

MongoDB+Spring MVC,mongodb,spring-mvc,Mongodb,Spring Mvc,我正在做一个结合SpringMVC和Mongodb的项目 数据库结构 Bean类结构 我得到以下错误 SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/avisweb] threw exception [Request processing failed; nested exception is o org.springframework.data.mapping.model

我正在做一个结合SpringMVC和Mongodb的项目

数据库结构 Bean类结构 我得到以下错误

SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/avisweb] threw      exception [Request processing failed; nested exception is   o  org.springframework.data.mapping.model.MappingException: No property status found on com.avis.bean.Agreement!] with root cause
org.springframework.data.mapping.model.MappingException: No property status found on com.avis.bean.Agreement!
at   org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:228)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:206)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:194)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:714)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:605)
at org.springframework.data.mongodb.core.convert.QueryMapper.createPropertyField(QueryMapper.java:152)
at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:113)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1515)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1506)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:532)

当您创建实体Bean类时,您有@Column Name,其中写入了您在数据库中声明的列名,并在初始值中声明了任何名称

,所以,让我直截了当地说:您与avis.com签订了合同,不必费心解释您自己到目前为止为解决该问题所做的工作,并期望我们解决它?我很有礼貌。。。但从我看到的情况来看,您在文档中有一个字段状态,您试图通过大写的字段名status注释来访问它。另外两个注意事项:它可能值得一读,并采取实际使用状态或状态双向,它将不会访问mongotemplate。我认为它并没有很好地映射到实体类和集合,所以当我们使用大写的数据库字段时,plaese建议我如何映射bean类
@Document
public class Agreement {

  @Id
  private String id;

  private String eRA;
  private AgreementId agreementId; // /Aggrement No
  private String agreementNumber;
  private String RLAddr; // // RL
  private String Salut; // // Salut
  private String GuestName; // //GuestName ;
  private String GuestCompShortName; // / Company;
  private String VehNum; // / vechileNumber
  private String ChauffName; // / Driver
  private String RentalType; // / RentalType
  private String AddressRL; // / reportingAddress
  private String RptDate; // / RptDate + RptTime reportingDateTime
  private String RptTime; // / RptDate + RptTime reportingDateTime
  private String deviceTimestamp; // ///
  private String tag;
  private String curentLocation;

  @Field("Status")
  private String Status; // // eRAStatus
  private String gps;
  private String type;
  private String grps;
  private Map<String, Map<String, Double>> logs;
  private String isRead;
  private String name;

  public String getType() {
    return this.getStatus();
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public void setType(String type) {
    this.type = type;
  }

public String getIsRead() {
    return isRead;
}

public void setIsRead(String isRead) {
    this.isRead = isRead;
}

public String geteRA() {
    this.id = this.id.replace("{ \"AgreementNo\" :", "")
            .replace(" \"SubNo\" : ", "").replace("}", "")
            .replace(",", "-");

    return this.id;
}

public void seteRA(String eRA) {
    this.eRA = eRA;
}

public AgreementId getAgreementId() {
    return agreementId;
}

public void setAgreementId(AgreementId agreementId) {
    this.agreementId = agreementId;
}

public String getRLAddr() {
    return RLAddr;
}

public void setRLAddr(String rLAddr) {
    RLAddr = rLAddr;
}

public String getSalut() {
    return Salut;
}

public void setSalut(String salut) {
    Salut = salut;
}

public String getGuestName() {

    return GuestName;
}

public void setGuestName(String guestName) {
    GuestName = guestName;
}

public String getGuestCompShortName() {
    return GuestCompShortName;
}

public void setGuestCompShortName(String guestCompShortName) {
    GuestCompShortName = guestCompShortName;
}

public String getVehNum() {
    return VehNum;
}

public void setVehNum(String vehNum) {
    VehNum = vehNum;
}

public String getChauffName() {
    return ChauffName;
}

public void setChauffName(String chauffName) {
    ChauffName = chauffName;
}

public String getRentalType() {
    String rtype = null;
    if (RentalType == "1" || RentalType.equalsIgnoreCase("1")) {
        rtype = "Local Run";
    } else if (RentalType == "2" || RentalType.equalsIgnoreCase("2")) {
        rtype = "Out Station";
    } else if (RentalType == "3" || RentalType.equalsIgnoreCase("3")) {
        rtype = "Transfer";
    } else if (RentalType == "4" || RentalType.equalsIgnoreCase("4")) {
        rtype = "Package";
    } else if (RentalType == "5" || RentalType.equalsIgnoreCase("5")) {
        rtype = "self Drive";
    } else if (RentalType == "6" || RentalType.equalsIgnoreCase("6")) {
        rtype = "LTR";
    }
    return rtype;
}

public void setRentalType(String rentalType) {
    RentalType = rentalType;
}

public String getAddressRL() {
    return AddressRL;
}

public void setAddressRL(String addressRL) {
    AddressRL = addressRL;
}

public String getRptDate() {
    String d = RptDate.substring(4, 6) + "-" + RptDate.substring(6, 8)
            + "-" + RptDate.substring(0, 4);
    return d + " " + RptTime;
}

public void setRptDate(String rptDate) {
    RptDate = rptDate;
}

public String getRptTime() {
    return RptTime;
}

public void setRptTime(String rptTime) {
    RptTime = rptTime;
}

public String getDeviceTimestamp() {
    return deviceTimestamp;
}

public void setDeviceTimestamp(String deviceTimestamp) {
    this.deviceTimestamp = deviceTimestamp;
}

public String getTag() {
    return tag;
}

public void setTag(String tag) {
    this.tag = tag;
}

public String getCurentLocation() {
    return curentLocation;
}

public void setCurentLocation(String curentLocation) {
    this.curentLocation = curentLocation;
}

public String getStatus() {
    String str = null;
    if (Status == "1" || Status.equals("1")) {
        Status = "Received from Carpro";
    } else if (Status == "2" || Status.equals("2")) {
        Status = "Complete Close";
    } else if (Status == "3" || Status.equals("3")) {
        Status = "Recall";
    } else if (Status == "4" || Status.equals("4")) {
        Status = "Accepted";
    } else if (Status == "5" || Status.equals("5")) {
        Status = "Start Journey";
    } else if (Status == "6" || Status.equals("6")) {
        Status = "Reached Pickup location";
    } else if (Status == "7" || Status.equals("7")) {
        Status = "Reached Drop off location";
    } else if (Status == "8" || Status.equals("8")) {
        Status = "Duty completed";
    } else if (Status == "9" || Status.equals("9")) {
        Status = "Expense Pending";
    } else if (Status == "10" || Status.equals("10")) {
        Status = "Didn't used";
    } else if (Status == "11" || Status.equals("11")) {
        Status = "Didn't arrive";
    } else if (Status == "12" || Status.equals("12")) {
        Status = "Break Down";
    } else if (Status == "13" || Status.equals("13")) {
        Status = "Exchange";
    } else if (Status == "14" || Status.equals("14")) {
        Status = "Dispatched to mobile";
    } else if (Status == "15" || Status.equals("15")) {
        Status = "Not Mapped or not delivered to mobilee";
    } else if (Status == "16" || Status.equals("16")) {
        Status = "Not Accepted";
    } else if (Status == "17" || Status.equals("17")) {
        Status = "Start Button Not Pressed";
    } else if (Status == "18" || Status.equals("18")) {
        Status = "Pickup Button not Pressed";
    } else if (Status == "19" || Status.equals("19")) {
        Status = "Closure status not received";
    } else if (Status == "20" || Status.equals("20")) {
        Status = "No GPRS";
    } else if (Status == "21" || Status.equals("21")) {
        Status = "No GPS";
    } else if (Status == "22") {
        Status = "Didn't communicate to fleet";
    }
    return Status;
}

public void setStatus(String status) {
    Status = status;
}

public String getAgreementNumber() {

    return agreementNumber;
}

public void setAgreementNumber(String agreementNumber) {
    this.agreementNumber = agreementNumber;
}

public String getId() {

    return id;
}

public void setId(String id) {
    this.id = id;
}

public Map<String, Map<String, Double>> getLogs() {
    return logs;
}

public void setLogs(Map<String, Map<String, Double>> logs) {
    this.logs = logs;
}

public String getGps() {
    if (this.Status == "21" || this.Status.equalsIgnoreCase("21"))
        return "YES";
    else
        return "NO";
}

public void setGps(String gps) {
    this.gps = gps;
}

public String getGrps() {
    if (this.Status == "20" || this.Status.equalsIgnoreCase("20"))
        return "YES";
    else
        return "NO";
}

public void setGrps(String grps) {
    this.grps = grps;
}

@Override
public String toString() {
    // TODO Auto-generated method stub
    return RLAddr + " >>> " + Salut + ">>>>>>> " + id + "vdsvsdvs ";
}

}
query1.addCriteria(Criteria.where("Status").is("constant"));
mongoTemplate.find(query1, Agreement.class, "eRA_live_v1");
SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/avisweb] threw      exception [Request processing failed; nested exception is   o  org.springframework.data.mapping.model.MappingException: No property status found on com.avis.bean.Agreement!] with root cause
org.springframework.data.mapping.model.MappingException: No property status found on com.avis.bean.Agreement!
at   org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:228)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:206)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:194)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:714)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:605)
at org.springframework.data.mongodb.core.convert.QueryMapper.createPropertyField(QueryMapper.java:152)
at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:113)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1515)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1506)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:532)