用hibernate,明明配置文件路劲正确,可是一直报错!求大神解救
这是我的文件结构
Grade.hbm.xml
hibernate.cfg.xml
org.hibernate.dialect.MySQLDialect
com.mysql.jdbc.Driver
root
123
jdbc:mysql://localhost:3306/wzl?useUnicode=true&characterEncoding=utf8
]]>
true
update
报错:
十月 08, 2016 12:51:42 下午 org.hibernate.annotations.common.Version
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
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) |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|
两个错误 一个是class的name属性为:com.wzl.entity.grade,显然不是什么com.imooc.*。第二个就是mapping那里映射请用反斜杠。 |
|
|
|
|