日期:2014-05-18  浏览次数:20815 次

一个简单的struts,spring整合Hibernate时,加载XML文件出错
User.hbm.xml如下:

<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<!DOCTYPE   hibernate-mapping   PUBLIC   "-//Hibernate/Hibernate   Mapping   DTD   2.0//EN "   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd "   >
       
<hibernate-mapping>
<!--  
        Created   by   the   Middlegen   Hibernate   plugin   2.1

        http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
-->

<class  
        name= "com.neusoft.vo.User "  
        table= "user "
>
   
        <id
                name= "id "
                type= "java.lang.String "
                column= "id "
        >
        <generator   class= "uuid.hex "   />
        </id>

        <property
                name= "username "
                type= "java.lang.String "
                column= "username "
                not-null= "true "
                length= "32 "
        />
     
        <property
                name= "password "
                type= "java.lang.String "
                column= "password "
                not-null= "true "
                length= "32 "
        />
             
     
        <!--   Associations   -->
   

</class>
</hibernate-mapping>


spring配置文件如下:

<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<!DOCTYPE   beans   PUBLIC   "-//SPRING//DTD   BEAN//EN "   "http://www.springframework.org/dtd/spring-beans.dtd ">
<beans>

<!--   定义数据源   -->
<bean   id= "dataSource "   class= "org.apache.commons.dbcp.BasicDataSource "   destroy-method= "close ">
    <property   name= "driverClassName ">
      <value> com.mysql.jdbc.Driver </value>
    </property>
    <property   name= "url ">
      <value> jdbc:mysql://localhost/test </value>