码迷,mamicode.com
首页 > 编程语言 > 详细

SSH框架整合遇到的错误——org.springframework.beans.NotWritablePropertyException:

时间:2018-06-30 21:53:45      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:private   except   ast   path   opera   rda   define   r.java   value   

提示错误信息:

Unable to instantiate Action, userAction,  defined for ‘user_registPage‘ in namespace ‘/‘Error creating bean with name ‘userAction‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userService‘ of bean class [com.itcast.shop.user.action.UserAction]: Bean property ‘userService‘ is not writable or has an invalid setter method. Did you mean ‘userservive‘? - action - file:/D:/Program%20Files%20(x86)/apache-tomcat-9.0.1/webapps/shop/WEB-INF/classes/struts.xml:36:56
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:320)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:401)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:201)
	org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:57)
	org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:32)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:60)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
	org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79)
	org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:141)

出现此问题的原因是在ApplicationContext.xml中配置有问题,里面的bean的属性名称用 与 注入的类名称不一致

applicationContext.xml

<!-- 用户模块的Action -->
<bean id="userAction" class="com.itcast.shop.user.action.UserAction" scope="prototype">
<property name="userService" ref="userService"/>
</bean>

userAction

private UserDao userdao;

private UserService userService;

public void setUserservive(UserService userService) {
this.userService = userService;
}

红色部分名称要一致。

 

SSH框架整合遇到的错误——org.springframework.beans.NotWritablePropertyException:

标签:private   except   ast   path   opera   rda   define   r.java   value   

原文地址:https://www.cnblogs.com/aishanyishi/p/9248684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!