为了账号安全,请及时绑定邮箱和手机立即绑定

生成表报错,代码都检查过了,没有什么问题啊,我用的是User不是Users

org.hibernate.MappingException: entity class not found: User

at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:129)

at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:390)

at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:75)

at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:145)

at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:507)

at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)

at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:385)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1790)

at entity.TestGoods.testSchemaExport(TestGoods.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.ClassNotFoundException: User

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:171)

at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)

at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:126)

... 37 more

http://img1.sycdn.imooc.com//5851412b0001688116000868.jpg

正在回答

4 回答

我说的是映射文件User.hbm.xml里的,你上面是配置文件hibernate.cfg.xml,你看看映射文件里是不是<class name="po.User" table="USERS">

0 回复 有任何疑惑可以回复我~
#1

晟晟online 提问者

没错啊,<class name="po.User" table="USER">
2016-12-16 回复 有任何疑惑可以回复我~
#2

晟晟online 提问者

问题解决了,Incomplete build path 和 Circular dependencies 由error改成warning就好了 ,不过,虽然junit不报错了,但是数据库没有出来表啊。
2016-12-16 回复 有任何疑惑可以回复我~
#3

晟晟online 提问者

非常感谢!
2016-12-16 回复 有任何疑惑可以回复我~
#4

慕粉4271541 回复 晟晟online 提问者

解决了就好,我也是尽我知道的回答你
2016-12-19 回复 有任何疑惑可以回复我~
查看1条回复

解决了吗?我也遇到类似问题

0 回复 有任何疑惑可以回复我~

我写的User在po包下,上边图片可以看到。。

0 回复 有任何疑惑可以回复我~

entity class not found User 的错误在于User在entity包下,那么映射文件中应为<class name="entity.User" table="USERS">

0 回复 有任何疑惑可以回复我~
#1

晟晟online 提问者

我写的User在po包下,上边图片可以看到。。
2016-12-15 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

生成表报错,代码都检查过了,没有什么问题啊,我用的是User不是Users

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信