• Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping


    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);


  • 相关阅读:
    WPF 快捷键读写txt
    win10 UWP GET Post
    win10 UWP GET Post
    win10 UWP Hmac
    win10 UWP Hmac
    win10 UWP MessageDialog 和 ContentDialog
    MySQL 触发器-更新字段时,status列会加一
    [SDOI2018]旧试题
    win10 UWP MessageDialog 和 ContentDialog
    win10 UWP RSS阅读器
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314645.html
Copyright © 2020-2023  润新知