Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path reso

本文分析了Spring配置Hibernate过程中出现的BeanCreationException异常原因,详细解释了错误信息中提到的找不到user.xml映射文件的问题,并提供了正确的配置示例。


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [user.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFacto


spring 配置文件 ,配置了一个  映射映射文件,有点不是很明白。这不是hibernate配置文件吗?spring中怎么又也要用到hibernate?


 <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  <property name="dataSource"  ref="dataSource"/>
  <property name="hibernateProperties">
  <props>
  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  <prop key="hibernate.show_sql" >true</prop>
  <prop key="hibernate.format_sql" >true</prop>
  <prop key="hibernate.hbm2ddl.auto">update</prop>
   </props>
   </property>
    <property name="mappingResources">
    <list>
     <value>user.xml</value>
    </list>
    </property> 

  </bean>


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值