spring整合hibernate启动Tomcat服务器时,控制台显示出错,大概内容如下:
Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.Configuration]: Constructor threw exception;
哪位大神帮忙解决以下,非常感谢。。。
spring整合hibernate时Tomcat出错
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
乔一只 2018-02-28 08:52关注那你要先去了解Spring集成hibernate 添加映射文件 有哪些方式,加载实体类的配置文件主要有4种方式:mappingResources,mappingLocations、mappingDirectoryLocations与mappingJarLocations
1. :就是你说的要列出每个具体的hbm.xml文件,这种方式对于映射文件不多时还好,当配置文件变得越来越多,阅读和修改起来也越来越麻烦了;
2. 这种方式只要指出映射文件所在文件夹就可以了,Spring会替你找出该文件夹内所有的映射文件,比如:
mypackage/mappings
3. :这种方式也可以指定任何文件路径,并且可以指定前缀:classpath、file等,也可以用通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名,如: 这应该就是你说的形式了;
4..mappingJarLocations:这种方式就是指定加载的映射文件在jar文件,这个你可以自己试下;解决 无用评论 打赏 举报