日期:2014-05-17  浏览次数:20764 次

Spring+Hibernate+Struts2项目的数据配置不能映射
Spring配置文件如下:
XML code
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/sciproject?useUnicode=true?amp;characterEncoding=UTF-8" />
        <property name="username" value="root" />
        <property name="password" value="root" />
        <property name="initialPoolSize" value="1" />
        <property name="minPoolSize" value="1" />
        <property name="maxPoolSize" value="40" />
        <property name="maxIdleTime" value="20" />
    </bean>
    
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResourses">
            <list>
                <value>cn/itcast/vo/Teacher.hbm.xml</value>
                <value>cn/itcast/vo/Thesis.hbm.xml</value>
                <value>cn/itcast/vo/Research.hbm.xml</value>
                <value>cn/itcast/vo/Literary.hbm.xml</value>
                <value>cn/itcast/vo/Achievement.hbm.xml</value>
            </list>
        </property>
    </bean>
    
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
</beans>




对应的映射文件如下(只列出其中一个):
Research.hbm.xml
XML code
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="cn.itcast.vo.Research" table="sci_research">
        <id name="researchId" type="java.lang.Integer" column="researchId" />
        <property name="researchName" type="java.lang.String" column="researchName" />
        <property name="rank" type="java.lang.String" column="rank" />
        <property name="leader" type="java.lang.String" column="leader" />
        <property name="leader_organization" type="java.lang.String"
            column="leader_organization" />
        <property name="sLeader" type="java.lang.String" column="sLeader" />
        <property name="sLeader_organization" type="java.lang.String"
            column="sLeader_organization" />
        <property name="publishDate" type="java.util.Date" column="publishDate" />
        <property name="expense" type="java.lang.String" col