- 完整报错提示信息:Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'blogDetailsService' of bean class [com.blog.action.BlogDetailsAction]: Bean property 'blogDetailsService' is not writable or has an invalid setter method. Did you mean 'blogDetailService'?
- 解决方案:
- 保证applicationContext.xml中注入的属性名称与com.blog.action.BlogDetailsAction中属性名称相同
1.1 applicationContext.xml:
<bean name="blogDetailsActionBean" class="com.blog.action.BlogDetailsAction"> <property name="blogDetailsService" ref="blogDetailsServiceImpl" /> </bean>
1.2 BlogDetailsAction.java
BlogDetailsService blogDetailsService; public BlogDetailsService getBlogDetailsService() { return blogDetailsService; } public void setBlogDetailService(BlogDetailsService blogDetailsService) { this.blogDetailsService = blogDetailsService; }
注:一般来说这样就可以解决问题了,但我这里不知道为什么必须将blogDetailsService全部都改成blogDetailService才可以运行。
原因:修改的struts.xml未生效。重开工作空间解决。