is not writable or has an invalid setter method错误的解决2009-02-10 16:15因为Spring要求注入的成员变量要按照Sun的命名规范,所以,注入变量名必须首字母小写
<!-- DAO -->
<bean id="commonuserDao"
class="cn.edu.ynu.sei.booki.persistence.dao.CommonUserDAO">
</bean>
<bean id="administratorDao"
class="cn.edu.ynu.sei.booki.persistence.dao.AdministratorDAO">
</bean>
<!-- 用户门户 -->
<bean id="userFacade"
class="cn.edu.ynu.sei.booki.facade.UserFacade">
<property name="commonuserDao">
<ref bean="commonuserDao" />
</property>
<property name="administratorDao">
<ref bean="administratorDao" />
</property>
</bean>
逻辑层的实现应该这样写:
public class UserFacade implements IUserFacade
{
IUserDAO commonuserDao = new CommonUserDAO();
IUserDAO administratorDao = new AdministratorDAO();
/**
* @return the commonuserDao
*/
public IUserDAO getCommonuserDao()
{
return commonuserDao;
}
/**
* @param administratorDao the administratorDao to set
*/
public void setAdministratorDao(IUserDAO administratorDao)
{
this.administratorDao = administratorDao;
}
。。。。
}
注意,其中commonuserDao,即属性必须首字母小写,而且不能在中间混有大写,否则会提示不可写或者没有setter方法或不可写!
我的错误:
Invalid property 'smsHistoryDao' of bean class [cn.com.mt2.besttone.web.SMSHistoryAction]: Bean property 'smsHistoryDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Unable to instantiate Action, smsHistoryAction, defined for 'inputQry' in namespace '/smsRcrd'Error creating bean with name 'smsHistoryAction' defined in file [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\haibaioam\WEB-INF\classes\spring\spring-actionContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'smsHistoryDao' of bean class [cn.com.mt2.besttone.web.SMSHistoryAction]: Bean property 'smsHistoryDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
javax.servlet.ServletException: Unable to instantiate Action, smsHistoryAction, defined for 'inputQry' in namespace '/smsRcrd'Error creating bean with name 'smsHistoryAction' defined in file [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\haibaioam\WEB-INF\classes\spring\spring-actionContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'smsHistoryDao' of bean class [cn.com.mt2.besttone.web.SMSHistoryAction]: Bean property 'smsHistoryDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
原因:
定义为SMSHistoryDaoImpl smsRcrdQryDAO;
public SMSHistoryDaoImpl getSmsRcrdQryDAO() {
return smsRcrdQryDAO;
}
public void setSmsRcrdQryDAO(SMSHistoryDaoImpl smsRcrdQryDAO) {
this.smsRcrdQryDAO = smsRcrdQryDAO;
}
应该改为:
SMSHistoryDaoImpl smsHistoryDao;
public SMSHistoryDaoImpl getSmsHistoryDao() {
return smsHistoryDao;
}
public void setSmsHistoryDao(SMSHistoryDaoImpl smsHistoryDao) {
this.smsHistoryDao= smsHistoryDao;
}
因为在配置文件中部署时,bean 的id是smsHistoryDao。
我也遇到上面的这种错误,主要原因是因为在把类定义成有下划线的变量,所以为了尽量不出现错误就不定义有下划线的类如: People_Child
分享到:
相关推荐
Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method. Does the parameter type ...
property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 这个问题我也在网上找了很久也没有好的解决方案,最后还是...
Invalid property 'error_view' of bean class [com.demo.controller.action.AuthorAction]: Bean property 'error_view' is not writable or has an invalid setter method. Does the parameter type of the ...
[com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of ...
Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method. Does the ...
dubbo-admin管理控制台安装... Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method.
dubbo-admin 在jdk1.8 环境下会出现Bean property 'URIType' is not writable or has an invalid setter,此版本通过替换citris,spring的低版本解决了这个问题
org.springframework.beans....: Bean property 'transactionManagerBeanName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 把其中的spring2的系列JAR包换成了spring3的,就可以在JDK8...
精通pl/sql part2
Storage Not Writable(解决方案).md
Directory Not Writable(解决方案).md
Backup Directory Not Writable(解决方案).md
Cache Directory Not Writable(解决方案).md
标题 "解决内存不能为read,write" 描述的是一个常见的计算机错误提示,通常在Windows操作系统中出现。这个错误表示程序在尝试访问内存时遇到了问题,可能是由于软件bug、硬件故障或者系统兼容性问题导致的。下面我们...
在某些情况下,内置的is_writable()函数可能无法正确地判断文件或目录的可写状态,比如在检查远程文件系统或某些特殊权限设置的情况下。这时,我们就可能需要自定义一个函数来模拟is_writable()的功能。 在给定的...
- **错误处理**:在使用`is_writable()`时,应考虑文件不存在或权限不足的情况,并给出适当的错误信息或处理策略。 以上内容涵盖了`is_writable()`函数的核心知识点,以及在实际开发中如何使用和注意事项。熟悉这些...