日期:2014-05-18  浏览次数:20751 次

org.hibernate.HibernateException: No CurrentSessionContext configured!
Beans.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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.2.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
  <context:annotation-config />
  <context:component-scan base-package="com.Alvin_yau"/>
  
  <bean id="addtionInterceptor" class="com.Alvin_yau.Spring.AOP.AddtionInterceptor"/>
  
  <aop:config>
        <aop:aspect id="addtionAspect" ref="addtionInterceptor">
             <aop:before method="Before" pointcut="execution(public * com.Alvin_yau.Spring.Service..*.save(..))"/>
        </aop:aspect>
  </aop:config>
  
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
  
  <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
   <property name="packagesToScan">
<list>
<value>com.Alvin_yau.Spring.Model</value>
</list>
</property>
  <property name="hibernateProperties">
    <props>
<prop key="hibernate.dialect">
 org.hibernate.dialect.OracleDialect
</prop>