当前位置: 代码迷 >> Java Web开发 >> Error reading resource: com/user/User.hbm.xml,该怎么解决
  详细解决方案

Error reading resource: com/user/User.hbm.xml,该怎么解决

热度:5806   发布时间:2013-02-25 21:11:05
Error reading resource: com/user/User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping 
package="com.user">
  <class name="User" table="user">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="bri"/>
</class>

</hibernate-mapping>



<?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">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/mysql
</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping resource="com/user/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>


这是2个配置文件,我在单位的时候可以运行,但是在房子却运行不了,一样的程序,
却出现这样的错误,在网上找了好久也没有解决,
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: Error reading resource: com/user/User.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at com.client.test.adduser(test.java:38)
at com.client.test.main(test.java:30)
Caused by: org.hibernate.MappingException: duplicate import: com.user.User
at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 8 more
谁帮我看看

------解决方案--------------------------------------------------------
不是同一台电脑吧?还是直接拷贝回来运行,有可能跟你的MyEclipse版本有关系,而且的你导包的时候如果直接使用MyEclipse 的库的话,换编译器就可能出问题,要copy 所有jar至lib下。
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!