1、错误描述

java.lang.ExceptionInInitializerError

Caused by:org.hibernate.InvalidMappingException:Could not parse mapping document from resource com/you/model/Monkey.hbm.xml

Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping com.you.model.Monkey

2、错误原因

Configuration config = new Configuration();

config.addClass(Monkey.class);

ServiceRegistry serviceRegistry = new ServiceRegistry().applySettings(config.getProperties().buildServiceRegistry();

sessionFactory = config.buildSessionFactory(serviceRegistry);

3、解决办法

由于配置文件已经添加到Monkey.class,而config.addClass(Monkey.class);又重复添加,故需要将此注释掉

Configuration config = new Configuration();

//config.addClass(Monkey.class);

ServiceRegistry serviceRegistry = new ServiceRegistry().applySettings(config.getProperties().buildServiceRegistry();

sessionFactory = config.buildSessionFactory(serviceRegistry);

Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping的更多相关文章

  1. Atitit.解决org.hibernate.DuplicateMappingException: Duplicate class/entity mapping

    Atitit.解决org.hibernate.DuplicateMappingException: Duplicate class/entity mapping 1. 排除流程::: @Depreca ...

  2. Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource Caused by: org.hibernate.DuplicateMappingException: duplicate import: Person refers to both cn.itcast.

    此错误是说有两个相同的名字的配置文件,所以不知道查找哪个.解决方法就是把不需要的那个配置文件删除. 删除mapping中不需要的那个xml文件即可

  3. hibernate3 Duplicate class/entity mapping(异常)

    hibernate3 Duplicate class/entity mapping(异常) 代码:      Configuration config = new Configuration().ad ...

  4. 错误解决Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: pers.zhb.domain.Student column: classno (should be mapped with insert="false" update="false")

    1.在学习hibernate的一对多多对一关系的时候,出现了一下错误: 2.错误原因: 这是因为在配置student.hbm.xml的配置文件的时候出现了将两个属性映射到同一个字段: <?xml ...

  5. org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/book.hbm.xml 联网跑一跑

    org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/boo ...

  6. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  7. Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.qingmu.seller.entity.OrderMaster

    org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before ...

  8. 分享知识-快乐自己:Caused by: org.hibernate.tool.schema.extract.spi.SchemaExtractionException: More than one table found in namespace (, ) : Dept (XXX)

    在命名空间(,)中找到多个表 - SchemaExtractionException? 问题: 尝试在Java应用程序中使用Hibernate将一些值保存到表中时,我一直面临着这个奇怪的异常. 但是, ...

  9. Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

    docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/) sta ...

随机推荐

  1. Git知识总览(五) Git中的merge、rebase、cherry-pick以及交互式rebase

    上篇博客聊了<git分支管理之rebase 以及 cherry-pick相关操作>本篇博客我们就以Learning Git中的关卡进行展开.下方列举了LearningGit中的 merge ...

  2. vue项目实现记住密码到cookie功能(附源码)

    实现功能: 1.记住密码勾选,点登陆时,将账号和密码保存到cookie,下次登陆自动显示到表单内 2.不勾选,点登陆时候则清空之前保存到cookie的值,下次登陆需要手动输入 大体思路就是通过存/取/ ...

  3. HDU 5608 function [杜教筛]

    HDU 5608 function 题意:数论函数满足\(N^2-3N+2=\sum_{d|N} f(d)\),求前缀和 裸题-连卷上\(1\)都告诉你了 预处理\(S(n)\)的话反演一下用枚举倍数 ...

  4. BZOJ 3670: [Noi2014]动物园 [KMP]

    求这玩意: 对于字符串S的前i个字符构成的子串,既是它的后缀同时又是它的前缀,并且该后缀与该前缀不重叠,将这种字符串的数量记作num[i] 对1,000,000,007取模的结果 n≤5,L≤1,00 ...

  5. Oracle的order by的中文排序问题

    Oracle 中查询结果按照某个中文字段或者英文字母(包括 符号)排序,并不会得到我们预期的结果,因为对于中文与英文字母及符号,Oracle实际是按照其对应的ASCII码值排序的! 可以看到按照中文村 ...

  6. 读论文系列:Object Detection SPP-net

    本文为您解读SPP-net: Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition Motivat ...

  7. 【Tools】linux更改分辨率,解决虚拟机安装后太小的问题

    Linux更改屏幕分辨率 1,分辨率模式已存在 1)如何查询是否存在: 终端输入命令:xrandr,即会输出当前已存在的分辨率模式. 2)如何配置: 使用命令xrandr --output 显示器名称 ...

  8. Java线程池ThreadPoolExector的源码分析

    前言:线程是我们在学习java过程中非常重要的也是绕不开的一个知识点,它的重要程度可以说是java的核心之一,线程具有不可轻视的作用,对于我们提高程序的运行效率.压榨CPU处理能力.多条线路同时运行等 ...

  9. git命令行工作的正确姿势

    git命令行创建并提交新分支到mater分支的常规步骤 git branch new_branch git status 查看修改的文件 git add changed_files git commi ...

  10. visual studio code右侧的预览面板能关闭吗?

    https://segmentfault.com/q/1010000010082399   "editor.minimap.enabled":false