问题一:
Exception in thread "main" org.hibernate.boot.MappingNotFoundException:
Mapping (RESOURCE) not found : /com/domain/Customer.hbm.xml : origin(/com/domain/Customer.hbm.xml)
原因:
在配置mapping的时候默认src下多添了斜杆,导致路径不正确
<mapping resource="/com/domain/Customer.hbm.xml"/>
解决:
<mapping resource="com/domain/Customer.hbm.xml"/>
问题二:
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
原因:
//加载配置文件
Configuration conf = new Configuration();
//解决:添加.configure()方法,Configuration conf = new Configuration().configure();
//因为:如果不使用configure()方法,这时hibernate会在classpath下面寻找hibernate.properties文件,
如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常。