朱小熊 2017-11-11 04:02 采纳率: 75%
浏览 998
已采纳

帮我看下配置文件,dao层一直报错、求指导,谢谢

报的错:

Messages:
Could not obtain transaction-synchronized Session for current thread
File: org/springframework/orm/hibernate5/SpringSessionContext.java
Line number: 133
`



配置Spring-text.xml如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="
   http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/tx 
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/aop 
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<!-- **********************************************Admin************************************************ -->
<bean id="AdminAction" class="com.lanou.admin4ZND.controllor.AdminAction" scope="prototype">
    <property name="adminService" ref="AdminService"></property>
</bean>
<bean id="AdminService" class="com.lanou.admin4ZND.services.impl.AdminService">
    <property name="adminDao" ref="AdminDao"></property>
</bean>
<bean id="AdminDao" class="com.lanou.admin4ZND.Dao.impl.AdminDao">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>




<!-- **************************************************SESSIONFACTORY****************************************************************** -->
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <!--注入数据源, -->
    <property name="dataSource" ref="dataSource"></property>
    <!-- 配置别的属性 -->
    <property name="hibernateProperties">
        <props>
            <prop key="show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
        </props>
    </property>
    <property name="mappingLocations"
        value="classpath:com/lanou/ssh/entity/mappings/*.hbm.xml"></property>
</bean>
<!-- *******************************************DATASOURCE********************************************************** -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver" />
    <property name="jdbcUrl"
        value="jdbc:mysql://localhost:3306/ZND?characterEncoding=utf-8&amp;useSSL=false" />
    <property name="user" value="root" />
    <property name="password" value="root" />
    <property name="maxPoolSize" value="30"></property>
    <property name="minPoolSize" value="5" />
    <property name="acquireIncrement" value="1"></property>
</bean>
<!-- ************************************TRANSCATION********************************************* -->
<!-- 配置transactionManager -->
<bean id="transactionManager"
    class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="logicTx" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="insert*" propagation="REQUIRED" timeout="-1"
            read-only="false" rollback-for="java.long.Exception" isolation="DEFAULT" />
        <tx:method name="add*" propagation="REQUIRED" />
        <tx:method name="save*" propagation="REQUIRED" />

        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="remove*" propagation="REQUIRED" />

        <tx:method name="update*" propagation="REQUIRED" />

        <tx:method name="find*" propagation="REQUIRED" />
        <tx:method name="query*" propagation="REQUIRED" />
        <tx:method name="select*" propagation="REQUIRED" />
    </tx:attributes>

</tx:advice>

<!-- ******************************************AOP********************************************** -->
<aop:config>
    <!-- 配置切点 -->
    <aop:pointcut expression="execution(* com.lanou.ssh.service.impl.*.*(..))"
        id="pointcut" />
    <!-- 通知 -->
    <aop:advisor advice-ref="logicTx" pointcut-ref="pointcut" />
</aop:config>



  • 写回答

1条回答 默认 最新

  • 零起跑线 2017-11-11 06:17
    关注



    <aop:pointcut expression="execution(* com.lanou.ssh.service.impl.*.*(..))"
        id="pointcut" />
    这两段的路径是不是写错了?
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体