雪夜微舞 2017-03-01 14:56 采纳率: 40%
浏览 1518
已采纳

SSH框架整合中读取不到Spring的配置文件

求大神指导 下面附上源码:
错误提示:
严重: 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 [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: entity class not found: po.BizClaimVoucherDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: entity class not found: po.BizClaimVoucherDetail
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:125)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:191)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:135)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:485)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:133)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:286)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 21 more
Caused by: java.lang.ClassNotFoundException: po.BizClaimVoucherDetail
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:122)
... 34 more

Spring配置文件的位置在SRC下创建了一个resource的文件夹

applicationContext.xml的配置文件源码:

<bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name = "configLocation" value="classpath:Hibernate.cfg.xml"></property>
</bean> 


<!-- 实体类的bean   依赖注入-->
<bean id="bizCheckResult" class="com.bdqn.zzt.jboa.entity.BizCheckResult"></bean>
<bean id="bizClaimVoucher" class="com.bdqn.zzt.jboa.entity.BizClaimVoucher"></bean>
<bean id="bizClaimVoucherDetail" class="com.bdqn.zzt.jboa.entity.BizClaimVoucherDetail"></bean>
<bean id="sysDepartment" class="com.bdqn.zzt.jboa.entity.SysDepartment"></bean>
<bean id="sysEmployee" class="com.bdqn.zzt.jboa.entity.SysEmployee"></bean>
<bean id="sysPosition" class="com.bdqn.zzt.jboa.entity.SysPosition"></bean>

<!--数据层的bean  依赖注入  -->
<bean id = "userDaoImpl" class = "com.bdqn.zzt.jboa.dao.UserDaoImpl">
    <property name = "sessionFactory" ref = "sessionFactory"></property>
</bean>


<!--业务层的bean  依赖注入  -->
<bean id = "userBizImpl" class = "com.bdqn.zzt.jboa.biz.UserBizImpl">
    <property name = "userDao" ref = "userDaoImpl"></property>
</bean>


<!-- 事务的管理 -->
<bean id = "transactionManager" class = "org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name = "sessionFactory" ref = "sessionFactory"></property>
</bean>
<tx:advice id = "txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name = "get*" read-only="false"></tx:method>
        <tx:method name = "find*" ></tx:method>
        <tx:method name = "add*" ></tx:method>
        <tx:method name = "save*" ></tx:method>
        <tx:method name = "update*" ></tx:method>
        <tx:method name = "delete*" ></tx:method>
        <tx:method name = "merge" ></tx:method>
    </tx:attributes>
</tx:advice>
<aop:config>
    <aop:pointcut id = "serviceMethod" expression="execution(public * com.bdqn.zzt.jboa.biz.*.*(..))"></aop:pointcut>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"></aop:advisor>
</aop:config>

Web.xml的源码:
 <!--Spring 配置文件的存放位置  -->

<!--
contextConfigLocation
classpath:applicationContext.xml
-->

contextConfigLocation
classpath:applicationContext.xml

<!-- Spring 的监听器 WEB环境中启动Spring容器 -->
<!--
org.springframework.web.context.ContextLoaderListener
-->


org.springframework.web.context.ContextLoaderListener

<!-- OpenSessionInView过滤器的配置 使回sesstion的管理范围增加-->
<!--
OpenSessionInViewFilter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter


OpenSessionInViewFilter
*.action
-->


openSessionInViewFilter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

sessionFactoryBeanName
sessionFactory



openSessionInViewFilter
*.action

<!--Strurs2的核心过滤器配置 -->
<!--
struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter


struts2
/*
-->


struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter


struts2
/*

  • 写回答

5条回答 默认 最新

  • 每天进步一点_点 2017-03-02 02:09
    关注

    看看是不是hibernate配置文件的类BizClaimVoucherDetail的路径配置错误了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥40 单片机实验录制讲解视频
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动
  • ¥15 大一C语言期末考试,求帮助🙏🙏
  • ¥15 ch340驱动未分配COM
  • ¥15 Converting circular structure to JSON
  • ¥15 Onvif Device Manager提示“对操作"GetProfiles”的回复消息正文进行反序列化时出错”问题
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE