http://dev2dev.bea.com.cn/bbsdoc/20060124187.html 我是根据这个文章学习的。
运行的时候出现这样的错误:org.hibernate.MappingNotFoundException: resource: Person.hbm.xml not found我发现Person.hbm.xml文件是产生在 E:\workspace\HibernateMySQL\bin\net\echochina\hibernatetest\dao 目录下;然后我把文件从copy到E:\workspace\HibernateMySQL\bin目录下,就正常了。请问这是什么原因呢?----------------------------------------------------------------------------------运行后数据库中生成了一条记录,但是还有一个小问题,就是控制台报错:log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
不知道这个问题又该如何解决?----------------------------------------------------------------------------------
运行的时候出现这样的错误:org.hibernate.MappingNotFoundException: resource: Person.hbm.xml not found我发现Person.hbm.xml文件是产生在 E:\workspace\HibernateMySQL\bin\net\echochina\hibernatetest\dao 目录下;然后我把文件从copy到E:\workspace\HibernateMySQL\bin目录下,就正常了。请问这是什么原因呢?----------------------------------------------------------------------------------运行后数据库中生成了一条记录,但是还有一个小问题,就是控制台报错:log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
不知道这个问题又该如何解决?----------------------------------------------------------------------------------
至于Person.hbm.xml文件是需要项目来识别它是个配置文件,你eclipse项目建立时候默认的是把编译后文件夹指向bin下的,你放到那里面去,那项目就能识别出来了
<property name="mappingDirectoryLocations">
<list>
<value>classpath:config/hbm</value>
</list>
</property>
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:config/hbm</value>
</list>
</property>
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
如果只是用了HIBERNATE,想达到这个目的,要修改heibernate的配置文件hibernate.cfg.xml,在里面有配置相应文件的地方
比如<mapping resource="com/tds/hibernate/YljgInfo.hbm.xml" />
<mapping resource="com/tds/hibernate/UserInfo.hbm.xml" />
<mapping resource="com/tds/hibernate/BmInfo.hbm.xml" />
这样的
log4j:WARN Please initialize the log4j system properly.
是因为你没有导入log4j包,还要写log4j的一个文件
至于第一个问题,要在hibernate.cfg.xml中调整配置,将正确路径载入