简体   繁体   English

春季:Bean属性不可写或具有无效的setter方法

[英]Spring: Bean property is not writable or has an invalid setter method

I know this question has been asked multiple times but to my eyes everything is correct. 我知道这个问题已经被问过多次了,但是在我看来,一切都是正确的。 I've also deleted my code from Eclipse and let the IDE create the getters/setters but no avail. 我还从Eclipse中删除了我的代码,并让IDE创建了getters / setter方法,但无济于事。

Here's my error in weblogic: 这是我在weblogic中的错误:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'gpsDataAllStopsSql' of bean class [com.fedex.dire.webservices.direservice.dao.GPSDataDaoImpl]: Bean property 'gpsDataAllStopsSql' is not writable or has an invalid setter method. 由以下原因引起:org.springframework.beans.NotWritablePropertyException:Bean类[com.fedex.dire.webservices.direservice.dao.GPSDataDaoImpl]的无效属性'gpsDataAllStopsSql':Bean属性'gpsDataAllStopsSql'是不可写的或无效的setter方法。 Does the parameter type of the setter match the return type of the getter? setter的参数类型是否与getter的返回类型匹配?

Here's my Bean & Property in my context: 这是我上下文中的Bean和Property:

<bean id="dataDao" class="com.text.service.dao.DataDaoImpl" >
      <property name="dataSource" ref="dataSource" />
      <property name="gpsDataAllStopsSql">
          <value><![CDATA[SELECT A.XML_DATA,B.ADDR1,B.ADDR2,B.POSTALCODE  FROM GPS.EVENT_STAMP A LEFT OUTER JOIN DB.SCAN B ON  A.FAC_IORG_NBR=B.FACILITY AND A.SCANNER_DATE=B.SCANDATE AND A.SCANNER_ID=B.SCANNERID AND A.PD_START_TIME=B.PDSTART WHERE FAC_IORG_NBR = ?  AND SCANNER_DATE = CAST(? AS DATE) AND SCANNER_ID = ? AND PD_START_TIME = ?]]></value>
    </property> 
      <property name="gpsDataSql">
          <value><![CDATA[SELECT A.XML_DATA,A.STOP_NUMBER,B.ADDR1,B.ADDR2,B.POSTALCODE FROM GPS.EVENT_STAMP A LEFT OUTER JOIN DB.SCAN B ON  A.STOP_NUMBER=B.STOP# AND A.FAC_IORG_NBR=B.FACILITY AND A.SCANNER_DATE=B.SCANDATE AND A.SCANNER_ID=B.SCANNERID AND A.PD_START_TIME=B.PDSTART WHERE FAC_IORG_NBR = ?  AND SCANNER_DATE = CAST(? AS DATE) AND SCANNER_ID = ? AND PD_START_TIME = ? AND STOP_NUMBER = ?]]></value>
 </property> 
 </bean>

Here are the getter and setter methods in my DaoImpl: 这是我的DaoImpl中的getter和setter方法:

private static String gpsDataSql = null;

private static String gpsDataAllStopsSql = null;

public static String getGpsDataSql() {
    return gpsDataSql;
}

public static void setGpsDataSql(String gpsDataSql) {
    DataDaoImpl.gpsDataSql = gpsDataSql;
}

public static String getGpsDataAllStopsSql() {
    return gpsDataAllStopsSql;
}

public static void setGpsDataAllStopsSql(String gpsDataAllStopsSql) {
    DataDaoImpl.gpsDataAllStopsSql = gpsDataAllStopsSql;
}

Is there something my eyes are gliding over or could it be another issue with my environment? 我的眼睛是否有滑过的东西,或者这可能是我周围环境的另一个问题?

Thanks! 谢谢!

The bean you are declaring in the XML tries to set properties that exists on the DataDaoImpl class. 您在XML中声明的Bean尝试设置DataDaoImpl类上存在的属性。 For this to work properly, remove the static members and try the following for your class: 为了使它正常工作,请删除静态成员,然后为您的课程尝试以下操作:

package com.text.service.dao;

public class DataDaoImpl extends SomeOtherDaoWhereDataSourceIsDefined {
    private String gpsDataAllStopsSql;
    private String gpsDataSql;

    public String getGpsDataAllStopsSql() {
        return gpsDataAllStopsSql;
    }

    public void setGpsDataAllStopsSql(String gpsDataAllStopsSql) {
        this.gpsDataAllStopsSql = gpsDataAllStopsSql;
    }

    public String getGpsDataSql() {
        return gpsDataSql;
    }

    public void setGpsDataSql(String gpsDataSql) {
        this.gpsDataSql = gpsDataSql;
    }
}

This article explains the usage of static vs non static members. 本文介绍了静态成员与非静态成员的用法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Bean属性'xxx'不可写或具有无效的setter方法 - Spring Bean property 'xxx' is not writable or has an invalid setter method NotWritablePropertyException:Bean属性“ dataSource”不可写或具有无效的setter方法 - NotWritablePropertyException: Bean property 'dataSource' is not writable or has an invalid setter method Bean属性“transactionManagerBeanName”不可写或具有无效的setter方法 - Bean property 'transactionManagerBeanName' is not writable or has an invalid setter method Bean属性xxxDAO无法写或具有无效的setter方法 - Bean property xxxDAO is not writable or has an invalid setter method Bean属性“ channelIdentifierMap”不可写或具有无效的setter方法 - Bean property 'channelIdentifierMap' is not writable or has an invalid setter method Bean属性“ bagBisDomainService”不可写或具有无效的setter方法 - Bean property 'bagBisDomainService' is not writable or has an invalid setter method Bean 属性“sessionFactory”不可写或具有无效的 setter 方法 - Bean property 'sessionFactory' is not writable or has an invalid setter method 是否可以使Spring忽略不可写或具有无效setter方法的bean属性 - Is it possible to make Spring ignore a bean property that is not writable or has an invalid setter method bean类的属性&#39;profileManager&#39;无效。 Bean属性“profileManager”不可写或具有无效的setter方法 - Invalid property 'profileManager' of bean class. Bean property 'profileManager' is not writable or has an invalid setter method Bean类的无效属性不可写或无效的setter方法 - Invalid property of bean class is not writable or an invalid setter method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM