导入所需要的jar包: xwork-core-2.2.1.jarxwork-core-2.2.1.jar struts2-spring-plugin-2.2.1.jarstruts2-spring-plugin-2.2.1.jar struts2-cor

  1. <?xml version= "1.0"  encoding= "UTF-8" ?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"   
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context= "http://www.springframework.org/schema/context"   
  4.     xmlns:aop="http://www.springframework.org/schema/aop"  xmlns:tx= "http://www.springframework.org/schema/tx"   
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans   
  6.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  7.            http://www.springframework.org/schema/context   
  8.            http://www.springframework.org/schema/context/spring-context-2.5.xsd   
  9.            http://www.springframework.org/schema/aop   
  10.            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd   
  11.            http://www.springframework.org/schema/tx    
  12.            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">   
  13.     <!-- 用注解方式注入bean,启动服务器时,spring会到com.yj查找所有带spring的注解(如:@Component ),把他们注入到spring中 -->  
  14.     <context:annotation-config/>  
  15.     <context:component-scan base-package = "com.yj" />  
  16.     <!-- hibernate sessionFactory 创建 -->  
  17.     <bean id="sessionFactory"   class = "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >  
  18.         <property name="packagesToScan" >  
  19.             <list>  
  20.                 <value>com.yj.model</value>  
  21.             </list>  
  22.         </property>  
  23.         <property name="hibernateProperties" >  
  24.             <props>  
  25.                 <prop key="hibernate.format_sql" > true </prop>  
  26.                 <prop key="hibernate.hbm2ddl.auto" >auto</prop>  
  27.                 <prop key="hibernate.show_sql" > true </prop>  
  28.                 <prop key="hibernate.dialect" >org.hibernate.dialect.Oracle10gDialect</prop>  
  29.                 <!--指定Proxool的alias,必须与Proxool的配置文件中的alias一致-->      
  30.                 <prop key="hibernate.proxool.pool_alias" >datasource</prop>    
  31.                 <!--指定Proxool配置文件-->     
  32.                 <prop key="hibernate.proxool.xml" >proxool.xml</prop>    
  33.                 <prop key="hibernate.connection.provider_class" >    
  34.                     org.hibernate.connection.ProxoolConnectionProvider    
  35.                 </prop>   
  36.             </props>  
  37.         </property>  
  38.     </bean>  
  39.      <bean id="hibernateTemplate"   class = "org.springframework.orm.hibernate3.HibernateTemplate" >  
  40.         <property name="sessionFactory"  ref= "sessionFactory" ></property>  
  41.      </bean>       
  42.      <!-- 事物配置 -->  
  43.      <bean id="transactionManager"   class = "org.springframework.orm.hibernate3.HibernateTransactionManager" >  
  44.         <property name="sessionFactory"  ref= "sessionFactory" ></property>  
  45.      </bean>  
  46.      <tx:advice id="txAdvice"  transaction-manager= "transactionManager" >  
  47.         <tx:attributes>  
  48.             <tx:method name="find*"  read-only= "true" />  
  49.             <tx:method name="add*"  propagation= "REQUIRED" />  
  50.             <tx:method name="save*"  propagation= "REQUIRED" />  
  51.         </tx:attributes>  
  52.      </tx:advice>  
  53.      <aop:config>  
  54.         <aop:pointcut expression="execution(public * com.yj.service..*.*(..))"  id= "myPointcut" />  
  55.         <aop:advisor advice-ref="txAdvice"  pointcut-ref= "myPointcut" />  
  56.      </aop:config>  
  57.        
  58. </beans> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值