问题:配置好aplicationContext.xml,启动tomcat  出现如下问题  sessionFactory无法正常建立

Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [aplicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Mapping directory location [ServletContext resource [/pw/dist/bos/entity]] does not denote a directory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Mapping directory location [ServletContext resource [/pw/dist/bos/entity]] does not denote a directory
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 21 more
三月 17, 2017 11:33:54 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [aplicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Mapping directory location [ServletContext resource [/pw/dist/bos/entity]] does not denote a directory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Mapping directory location [ServletContext resource [/pw/dist/bos/entity]] does not denote a directory
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 21 more

解决方案:引入配置文件解决  当然还有

<property name="configLocations" value="classpath:hibernate.cfg.xml">
mappingLocations:可以指定任何文件路径,
<property name="mappingLocations">
<value>/WEB-INF/User.hbm.xml </value>
</property>
可以指定前缀:classpath、file等   

<property name="mappingLocations"> <value>classpath:/com/cy/www/User.hbm.xml </value> </property> 也可以用通配符指定,'*'指定一个文件(路径)名,: <property name="mappingLocations"> <value>classpath:/com/cy/www/*.hbm.xml </value>


</property> 上面的配置是在com/company/domain包下任何maps路径下的hbm.xml文件都被加载为映射文件 mappingDirectoryLocations:指定映射的文件路径 <property name="mappingDirectoryLocations"> <list> <value>WEB-INF/HibernateMappings</value> </list> </property> 也可以通过classpath来指出 <property name="mappingDirectoryLocations">
<list> <value>classpath:/XXX/package/</value> </list> </property>

												

sessionFactory' defined in class path /mappingDirectoryLocations配置问题的更多相关文章

  1. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  2. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

  3. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable t

    spring与hibernate整合然后出现如下错误: org.springframework.beans.factory.BeanCreationException: Error creating ...

  4. 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]

    报这种错的原因基本上是applicationContext.xml文件中bean配置错误,错误如下: org.springframework.beans.factory.BeanCreationExc ...

  5. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is

    在复制xml文件进行修改的时候,我经常将不小心对原文件进行修改,而导致创建bean出错.报错如下所示: Exception sending context initialized event to l ...

  6. 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class p

    严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener]org.springframework ...

  7. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [spring/applicationContext-service.xml]: Cannot resolve refer

    <!-- aop --> <aop:config> <aop:pointcut expression="execution(* com.zsn.Service. ...

  8. 错误/异常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/beans_common.xml]...的解决方法

    1.第一个这种类型的异常 1.1.异常信息:org.springframework.beans.factory.BeanCreationException: Error creating bean w ...

  9. Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案

    ​ 项目是集成了Spring Boot和Spring Data,然后昨天简单Jpa和Spring Boot配置完成,开始进行公司项目的重构,然后出现了这个问题.当时是在网上找了好久.后来发现时java ...

随机推荐

  1. 6 vue-element.ui 左侧导航栏

    <template> <div> <el-menu :default-active="'/'+activeIndex2" mode="ver ...

  2. Java Jar源码反编译工具那家强

    本文介绍下Java Jar常见的反编译工具,并给出使用感受. 反编译JAR能干什么: 排查问题.分析商业软件代码逻辑,学习优秀的源码思路. JD-GUI 下载地址:http://java-decomp ...

  3. 剑指 Offer 43. 1~n整数中1出现的次数

    题目描述 输入一个整数 n ,求1-n这n个整数的十进制表示中1出现的次数. 例如,输入12,1-12这些整数中包含1 的数字有1.10.11和12,1一共出现了5次. 示例 1: 输入:n = 12 ...

  4. Linux系统安装01-centos7系统安装

    2020注定是一个不平凡的年份,对于各行各业都是不小的波动.话说回来,从当前的互联网趋势来看,linux的使用以后会越来越广泛,既然之前不懂linux,那么我们就从头开始,先学习Linux的系统安装. ...

  5. docker下部署jira破解版

    1. 制作Docker破解容器 在/opt/jira下新建一个Dockerfile文件 touch Dockerfile 编辑Dockerfile文件 vim Dockerfile FROM cpta ...

  6. centos下安装mongodb和php的mongo扩展

    安装MongoDB 1.下面安装MongoDB,先下载: cd /usr/src wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2 ...

  7. 解压gzip格式文件(包括网页)

    先上源码 参数说名: - source :gzip格式流内容. - len: gzip流长度 - dest: 解压后字符流指针 - gzip: 压缩标志,非0时解压gzip格式,否则按照zip解压 说 ...

  8. [LeetCode]64. 最小路径和(DP)

    题目 给定一个无序的整数数组,找到其中最长上升子序列的长度. 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4 ...

  9. 月薪20k的java面试题他来了

    1.场景描述 最近有朋友私信,说网上的面试资料有点散,还有些过时的,问老王能否帮忙整理下,老王晚上刚好有空,就给梳理了下,分享给大家. 2.解决方案 2.1 说明 (1)面试的题目多数是从网上找的,老 ...

  10. js之按钮切换

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...