spring带参类构造器报错
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginActionBean' defined in file [D:\TOMCAT\apache-tomcat-6.0.20\webapps\Test4\WEB-INF\classes\applicationContext-actions.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userServDao' of bean class [com.test.action.Login]: Bean property 'userServDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'userServDao' of bean class [com.test.action.Login]: Bean property 'userServDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
xml配置文件
<bean id="userServImpl" class="com.test.service.impl.UserServImpl"
abstract="false" autowire="constructor" dependency-check="default">
<constructor-arg type="com.test.dao.impl.LoginDaoImpl">
<ref bean="loginDaoImpl" />
</constructor-arg>
</bean>
<bean id="loginDaoImpl" class="com.test.dao.impl.LoginDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
public class UserServImpl extends BaseServImpl<User, Long> implements BaseServ<User, Long> {
public UserServImpl(LoginDao logindao){
super(logindao);
}
}
--------------------编程问答-------------------- 报错误的类,跟你贴出来的这个类,似乎没啥关系啊?
Spring构造出错的类是:bean class [com.test.action.Login]
原因是:Bean property 'userServDao' is not writable
这个属性userServDao无法设置,或者找不到setter
补充:Java , Web 开发