springMVC报错,请教大神!

最近在学习springMVC,搭建好框架后,报出了如下错误,求大神指教:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManagerBase' defined in file [F:\Software\apache-tomcat-7.0.65\webapps\spring\WEB-INF\classes\comm\buaa\xml\spring-user.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'uersDao' of bean class [comm.buaa.service.impl.UserService]: Bean property 'uersDao' is not writable or has an invalid setter method. Did you mean 'usersDao'?
我的项目结构:
图片说明
spring-hibernate.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" 
"http://www.springframework.org/dtd/spring-beans-2.0.dtd" [
<!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml">
]>
<!-- 该配置用来加载数据源,设置sessionFactory,作为spring配合文件存在,是最底层,最基础的配置 。
    总览hibernate等其他的配置。
-->
<beans>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:ORCL"></property>
        <property name="username" value="zq"/>
        <property name="password" value="zq123"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop> 
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hiberante.format_sql">true</prop>
            </props>
        </property>
        <property name="configLocations">
            <list>
                <value>classpath:comm/buaa/hibernate/user.cfg.xml</value>
            </list>
        </property>
    </bean>


    <!-- 代理事务处理 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!-- 事务基类,加载bean -->
    <bean id="transactionBese" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" 
    lazy-init="true" abstract="true">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transactionAttributes">
            <props>
                <prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>
                <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
                <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
                <prop key="modi*">PROPAGATION_REQUIRED,-Exception</prop>
                <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
                <prop key="get*">PROPAGATION_NEVER</prop>
            </props>
        </property>
    </bean> 
</beans>

spring-core.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" 
"http://www.springframework.org/dtd/spring-beans-2.0.dtd" [
<!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml">
]>

<beans>
    <import resource="comm/buaa/xml/spring-user.xml"/>
</beans>

spring-user.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" 
"http://www.springframework.org/dtd/spring-beans-2.0.dtd" [
<!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml">
]>
<beans>
    <bean id="uersDao" class="comm.buaa.dao.impl.UserDao">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <!-- 为service层加载事务 -->
    <bean id="userManagerBase" class="comm.buaa.service.impl.UserService">
        <property name="uersDao" ref="uersDao"/>
    </bean>
    <!-- parent继承spring-hibernate.xml的事务id, id="userService"
        指的是comm.buaa.control.UserControl的属性
    -->
    <bean id="userService" parent="transactionBese">
        <property name="target" ref="userManagerBase"/>
    </bean>
</beans>

user.cfg.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <mapping class="comm.buaa.bean.Users"/>
    </session-factory>
</hibernate-configuration>

UserService.java

 package comm.buaa.service.impl;

import comm.buaa.bean.Users;
import comm.buaa.dao.IUserDao;
import comm.buaa.service.IUserService;

public class UserService implements IUserService{

    private IUserDao usersDao;

    public void setUsersDao(IUserDao usersDao) {
        this.usersDao = usersDao;
    }
        public IUserDao getUsersDao(){
               return usersDao;
        }
    public void addUser(Users user) {
        usersDao.addUser(user);
    }
}

2个回答

usersDAO 写错了,配置文件里是userDAO

csdn_flying97
csdn_flying97 对的,我的<property></property>的映射属性名不对,看来还是ctrl+c/ctrl+v实用啊!谢谢喽。。
3 年多之前 回复

用annocation自動注入,方便很多,不容易出錯

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!