...
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Two.Person //意思是重复的Two.person类
...
解决方法:
hibernate.cfg.xml 中session-factory ,配置了
<mapping resource="Two/Person.hbm.xml" />
此项和测试项app2中 .addClass(Person.class)冲突, 把hibernate.cfg.xml 中 的<mapping resource=""/> 注销即可
错误来源:
sf工厂小工具Person.class
sf = new Configuration().configure()
.addClass(Person.class) //(测试) 会自动加载映射文件:Person.hbm.xml
.buildSessionFactory();
hibernate.cfg.xml也有Person.hbm.xml(里面包含着Person类)
<session-factory>
<mapping resource="Two/Person.hbm.xml"/>
</session-factory>
所以爆出重复加载类的异常