ERROR 08 六月 2010 10:34:37 [org.springframework.web.context.ContextLoader] [initWebApplicationContext] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingManner

解决方案 »

  1.   

    ??
    Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingManner
    getXx()方法写错了吧
      

  2.   

    ERROR 08 六月 2010 10:47:42 [org.apache.catalina.core.StandardContext] [listenerStart] - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingManner启动tomcat时报错
      

  3.   

    Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingMannercom.baidu.manageSystem.machineRoom.dto.CollectingManner这个类里面没有getter和setter方法
      

  4.   

    public CollectingType getCollectingType() {
    return this.collectingType;
    } public void setCollectingType(CollectingType collectingType) {
    this.collectingType = collectingType;
    }
      

  5.   

    Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingManner
    collectingType  这个东西 在CollectingManner这个action里没有 getter 方法
      

  6.   

    去你的配置文件里看 mySessionFactory 这个 bean 属性 名字 跟类里写的是否一样
      

  7.   

    不可能啊   get方法我在action不曾用到啊
      

  8.   

    去xml文件看看!!看看配置出问题了没
      

  9.   

    依赖注入需要有get set方法
      

  10.   

    配置文件里bean配置的名字和方法里不一致.
      

  11.   

    不曾用到也要写的。只是spring的注入方式。
      

  12.   

    哦   我采用的主键是联合主键,所以实体类有2个,而collectingType 就在建立关系的那个实体类中
      

  13.   

    楼主  你的问题 。。不是说tomcat出了错而是你的配置文件没有配置好,】webapplicationinit  初始化出错啊还有就是 你那个Mysessionfactory 。你有没有生成setter getter 方法???更为重要的是 就是你那个 setter getter 方法  生成了 但是 你在 你的application-context。sml文件中配置了没有 ref =“”  你看看你知道哪里了?????
      

  14.   

    集合注入以及对象注入不仅需要用到setter还需要getter,否则会出现非预期的结果,对象注入时每注入一个属性后它会用getter检查是否注入成功,没有getter的话,它会新new一个对象进行第二个属性...一直到最后一个属性,因此某对象只以setter而没有getter的话,最后得到的对象只有最后一个属性不为null,集合也是同理.
      

  15.   

    package com.baidu.manageSystem.machineRoom.dto;import com.baidu.manageSystem.common.base.BaseDTO;/**
     * CollectingManner entity. @author MyEclipse Persistence Tools
     */public class CollectingManner extends BaseDTO implements java.io.Serializable { // Fields /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private CollectingMannerId id;
    private String chname;
    private String enname;
    private Double colletingDay;
    private Double Day; // Constructors /** default constructor */
    public CollectingManner() {
    } /** minimal constructor */
    public CollectingManner(CollectingMannerId id, String chname, String enname) {
    this.id = id;
    this.chname = chname;
    this.enname = enname;
    } /** full constructor */
    public CollectingManner(CollectingMannerId id, String chname,
    String enname, Double colletingDay) {
    this.id = id;
    this.chname = chname;
    this.enname = enname;
    this.colletingDay = colletingDay;
    } // Property accessors public CollectingMannerId getId() {
    return this.id;
    } public void setId(CollectingMannerId id) {
    this.id = id;
    } public String getChname() {
    return this.chname;
    } public void setChname(String chname) {
    this.chname = chname;
    } public String getEnname() {
    return this.enname;
    } public void setEnname(String enname) {
    this.enname = enname;
    } public Double getColletingDay() {
    return this.colletingDay;
    } public void setColletingDay(String colletingDay) {
    this.colletingDay = Day;
    }}
      

  16.   

    package com.baidu.manageSystem.machineRoom.dto;import com.baidu.manageSystem.common.base.BaseDTO;/**
     * CollectingMannerId entity. @author MyEclipse Persistence Tools
     */public class CollectingMannerId extends BaseDTO implements java.io.Serializable { // Fields private String id;
    private CollectingType collectingType; // Constructors /** default constructor */
    public CollectingMannerId() {
    } /** full constructor */
    public CollectingMannerId(String id, CollectingType collectingType) {
    this.id = id;
    this.collectingType = collectingType;
    } // Property accessors public String getId() {
    return this.id;
    } public void setId(String id) {
    this.id = id;
    } public CollectingType getCollectingType() {
    return this.collectingType;
    } public void setCollectingType(CollectingType collectingType) {
    this.collectingType = collectingType;
    } public boolean equals(Object other) {
    if ((this == other))
    return true;
    if ((other == null))
    return false;
    if (!(other instanceof CollectingMannerId))
    return false;
    CollectingMannerId castOther = (CollectingMannerId) other; return ((this.getId() == castOther.getId()) || (this.getId() != null
    && castOther.getId() != null && this.getId().equals(
    castOther.getId())))
    && ((this.getCollectingType() == castOther.getCollectingType()) || (this
    .getCollectingType() != null
    && castOther.getCollectingType() != null && this
    .getCollectingType().equals(
    castOther.getCollectingType())));
    } public int hashCode() {
    int result = 17; result = 37 * result + (getId() == null ? 0 : this.getId().hashCode());
    result = 37
    * result
    + (getCollectingType() == null ? 0 : this.getCollectingType()
    .hashCode());
    return result;
    }}联合主键自动生成的两个实体类,请高手指教,要不要对他们两个实体类都操作
      

  17.   


    Could not find a getter for collectingType in class com.baidu.manageSystem.machineRoom.dto.CollectingManner
    public class CollectingManner extends BaseDTO implements java.io.Serializable {
       private static final long serialVersionUID = 1L;
        private CollectingMannerId id;
        private String chname;
        private String enname;
        private Double colletingDay;
        private Double Day;
    CollectingManner 是没有collectingType 的get set 啊, 楼主配置不对吧。
    不应该把collectingType  配到CollectingManner 中的吧。SPRING 已经没用很久了。 但看错误 应该还是配置的不对。 或者说写的类和配置不对应。 
      

  18.   

    collectingType 这个东西 在CollectingManner这个action里没有 getter 方法
      

  19.   

    bean的id首字母需要小写。使用setter()注入bean