当前位置:编程学习 > JAVA >>

SSH 集成报错

SSH 集成报错 MySql数据库中只有Tuser表,新建多个项目添加SSH支持,选择这个数据库,部署启动Tomcat都会把这个错误,请高手解答,谢谢!


严重: action: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.zw.entity.TblZfxx
org.hibernate.MappingException: Association references unmapped class: com.zw.entity.TblZfxx


package com.zw.entity;

/**
 * Tuser entity. @author MyEclipse Persistence Tools
 */

public class Tuser implements java.io.Serializable {

// Fields

private Integer uid;
private String uname;
private String upass;

// Constructors

/** default constructor */
public Tuser() {
}

/** full constructor */
public Tuser(String uname, String upass) {
this.uname = uname;
this.upass = upass;
}

// Property accessors

public Integer getUid() {
return this.uid;
}

public void setUid(Integer uid) {
this.uid = uid;
}

public String getUname() {
return this.uname;
}

public void setUname(String uname) {
this.uname = uname;
}

public String getUpass() {
return this.upass;
}

public void setUpass(String upass) {
this.upass = upass;
}

}



<?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">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.zw.entity.Tuser" table="tuser" catalog="dbmysql">
        <id name="uid" type="java.lang.Integer">
            <column name="uid" />
            <generator class="identity" />
        </id>
        <property name="uname" type="java.lang.String">
            <column name="uname" length="20" />
        </property>
        <property name="upass" type="java.lang.String">
            <column name="upass" length="20" />
        </property>
    </class>
</hibernate-mapping>

--------------------编程问答-------------------- 这怎么看,把applicationContext.xml和struts.xml贴出来吧,不是Hibernate的原因 --------------------编程问答-------------------- Association references unmapped class: com.zw.entity.TblZfxx

com.zw.entity.TblZfxx是什么? --------------------编程问答-------------------- <?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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>
<property name="url"
value="jdbc:mysql://localhost:53306/dbmysql">
</property>
<property name="username" value="kzczuser"></property>
<property name="password" value="kzcz"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/zw/entity/Tuser.hbm.xml</value></list>
</property></bean>
<bean id="userDao" class="com.zw.dao.impl.UserDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="userBiz" class="com.zw.biz.impl.UserBizImpl">
<property name="userDaoImpl" ref="userDao"></property>
</bean>

<bean name="/reg" class="com.zw.struts.action.RegAction">
<property name="userBiz" ref="userBiz"></property>
</bean>

</beans>




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="regForm" type="org.apache.struts.action.DynaActionForm">
      <form-property name="userName" type="java.lang.String" />
      <form-property name="userPass" type="java.lang.String" />
    </form-bean>

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="regForm"
      input="/reg.jsp"
      name="regForm"
      path="/reg"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy"
      validate="false">
      <set-property property="cancellable" value="true" />
      <forward name="success" path="/success.jsp" />
    </action>

  </action-mappings>

  <message-resources parameter="com.zw.struts.ApplicationResources" />
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
   <set-property value="classpath:applicationContext.xml" property="contextConfigLocation"/>
  </plug-in>
</struts-config>

--------------------编程问答-------------------- org.hibernate.MappingException: Association references unmapped class: com.zw.entity.TblZfxx
报的是找不到com.zw.entity.TblZfxx,在applicationContext.xml你只配置了com/zw/entity/Tuser.hbm.xml
<list>
 <value>com/zw/entity/Tuser.hbm.xml</value>
</list>


我估计是你写错了,把com.zw.entity.Tuser写成了com.zw.entity.TblZfxx --------------------编程问答-------------------- 找找这个com.zw.entity.TblZfxx在哪,问题就解决了 --------------------编程问答-------------------- 之前我将数据库Zfxx表重新反向生成映射文件,再之后部署启动项目还是报这个错误,新建新的项目部署也会报这个错误,最后我将MyEclipseTomcat 换为Tomcat6.0部署,就没这个错误了,可能是MyEclipseTomcat的问题。 --------------------编程问答-------------------- --------------------编程问答-------------------- 配置问题,仔细检查
ssh,一个action,既要在struts.xml里,又要在application.xml里面配。 --------------------编程问答-------------------- 你的错误太明显了,是hibernate映射文件错误,你可以用myeclipse的自动给你生成的 --------------------编程问答-------------------- 严重: action: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.zw.entity.TblZfxx
org.hibernate.MappingException: Association references unmapped class: com.zw.entity.TblZfxx


com.zw.entity.TblZfxx找不到 --------------------编程问答-------------------- hbm.xml文件加了没???
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,