亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用hibernate,明明配置文件路勁正確,可是一直報錯!求大神解救

用hibernate,明明配置文件路勁正確,可是一直報錯!求大神解救

慕碼人2483693 2018-12-06 14:27:10
這是我的文件結構 <hibernate-mapping> <class name="com.imooc.entity.Grade" table="grade"> <id name="gid" column="gid" type="java.lang.Integer"> <generator class="increment"></generator> </id> <property name="gname" type="java.lang.String"> <column name="gname" length="20" not-null="true"></column> </property> <property name="gdesc"> <column name="gdesc"></column> </property> <!-- 配置一對多關聯關系 --> <set name="students" table="student"> <key column="gid"></key> <one-to-many class="com.wzl.entity.Student"/> </set> </class> </hibernate-mapping> hibernate.cfg.xml <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123</property> <property name="hibernate.connection.url"> <![CDATA[ jdbc:mysql://localhost:3306/wzl?useUnicode=true&characterEncoding=utf8 ]]> </property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <!-- 指定映射文件的路徑 --> <mapping resource="com.wzl.entity.Grade.hbm.xml"/> <mapping resource="com.wzl.entity.Student.hbm.xml"/> </session-factory> </hibernate-configuration> 報錯: 十月 08, 2016 12:51:42 下午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 十月 08, 2016 12:51:42 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.4.Final} 十月 08, 2016 12:51:42 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 十月 08, 2016 12:51:42 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 十月 08, 2016 12:51:42 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 十月 08, 2016 12:51:42 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 十月 08, 2016 12:51:42 下午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com.wzl.entity.Grade.hbm.xml Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.wzl.entity.Grade.hbm.xml not found at org.hibernate.cfg.Configuration.addResource(Configuration.java:738) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2188) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2160) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2140) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2093) at org.hibernate.cfg.Configuration.configure(Configuration.java:2008) at org.hibernate.cfg.Configuration.configure(Configuration.java:1987) at com.wzl.test.Test2.add(Test2.java:34) at com.wzl.test.Test2.main(Test2.java:20) 求大神解答
查看完整描述

3 回答

?
Smart貓小萌

TA貢獻1911條經驗 獲得超7個贊

Grade.hbm.xml配置文件中的<class name="com.imooc.entity.Grade" table="grade">應該為<class name="com.wzl.entity.Grade" table="grade">

查看完整回答
反對 回復 2018-12-16
?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.wzl.entity.Grade.hbm.xml not found

上邊的文件配置有問題

?

查看完整回答
反對 回復 2018-12-16
?
神不在的星期二

TA貢獻1963條經驗 獲得超6個贊

?映射文件資源路徑配置的問題,可以參考樓上回復

查看完整回答
反對 回復 2018-12-16
  • 3 回答
  • 0 關注
  • 718 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號