解決Bean property ** is not writable or has an invalid setter method

來源:互聯網
上載者:User

struts2+spring真讓人糾結……

 

遇到了Bean property ** is not writable or has an invalid setter method這樣的錯誤  正好找到個類似的解答

 

用SSH2架構,為某Action注入Bo時出現NotWritablePropertyException異常.當時是用同事已寫好的名字cMsgbo.但啟動tomcat時總拋出NotWritablePropertyException異常.詳細異常資訊如下:

Error creating bean with name '/count' defined in ServletContext resource [/WEB-INF/classes/kingtoonApplicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'cMsgbo' of bean class [com.kingtoon.count.struts.action.CountAction]: Bean property 'cMsgbo' is not writable or has an invalid setter method. Did you mean 'CMsgbo'?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'cMsgbo' of bean class [com.kingtoon.count.struts.action.CountAction]: Bean property 'cMsgbo' is not writable or has an invalid setter method. Did you mean 'CMsgbo'?

這個錯誤資訊最後問我是不是CMsgbo.於是乎我就隨便換成一名字,比如comBo.然後再次啟動Tomcat,伺服器順利啟動.

總結:可能Spring會檢查當前所起的名字是不是符合其規範以致可以認出是個什麼東西來.如果起的名字不是很明確的話,那spring會給你一個異常,提示你換個名字吧,當前這個名字我認不出來.照她說的做就沒問題了.

轉自 http://hi.baidu.com/kingtoon_go/blog/item/8bdf6b38416f462796ddd878.html

 

我自己用的時候是在Action中執行個體化介面的時候拼字不一致導致的

public class BtnClickAction extends ActionSupport{IBtnClickSumService btnClickSumService;

 

之前寫成

IBtnClickSumService btnClickService;

 

執行個體名少了幾個字母就不行了,

擦……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.