天天看點

spring hibernate struts

xml 代碼  

  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"  
  4.   xmlns:aop="http://www.springframework.org/schema/aop"  
  5.   xmlns:tx="http://www.springframework.org/schema/tx"  
  6.   xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd  
  8.            http://www.springframework.org/schema/aop  
  9.            http://www.springframework.org/schema/aop/spring-aop-2.0.xsd  
  10.                       http://www.springframework.org/schema/tx  
  11.                       http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">  
  12.   <bean id="propertyConfigurer"  
  13.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  14.     <property name="location" value="/WEB-INF/config/jdbc.properties"/>  
  15.   bean>  
  16.   <bean id="dataSource"  
  17.         class="com.mysql.jdbc.Driver"  
  18.         destroy-method="close">  
  19.     <property name="driverClass"><value>${driverClass}value>property>  
  20.     <property name="jdbcUrl"><value>${jdbcUrl}value>property>  
  21.     <property name="user"><value>${user}value>property>  
  22.     <property name="password"><value>${password}value>property>  
  23.     <property name="minPoolSize"><value>1value>property>  
  24.     <property name="maxPoolSize"><value>20value>property>  
  25.     <property name="maxIdleTime"><value>1800value>property>  
  26.     <property name="acquireIncrement"><value>2value>property>  
  27.     <property name="maxStatements"><value>0value>property>  
  28.     <property name="initialPoolSize"><value>2value>property>  
  29.     <property name="idleConnectionTestPeriod"><value>1800value>property>  
  30.     <property name="acquireRetryAttempts"><value>30value>property>  
  31.     <property name="breakAfterAcquireFailure"><value>truevalue>property>  
  32.     <property name="testConnectionOnCheckout"><value>falsevalue>property>  
  33.   bean>  
  34.   <bean id="sessionFactory"  
  35.         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
  36.     <property name="dataSource" ref="dataSource" />  
  37.     <property name="annotatedClasses">  
  38.       <list>  
  39.         <value>com.daniel.lr.crbt.share.db.Uservalue>  
  40.       list>  
  41.     property>  
  42.     <property name="hibernateProperties">  
  43.       <props>  
  44.         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialectprop>  
  45.         <prop key="hibernate.hbm2ddl.auto">updateprop>  
  46.         <prop key="hibernate.show_sql">trueprop>  
  47.         <prop key="hibernate.generate_statistics">trueprop>  
  48.         <prop key="hibernate.connection.release_mode">autoprop>                       
  49.         <prop key="hibernate.autoReconnect">trueprop>  
  50.         <prop key="hibernate.bytecode.use_reflection_optimizer">trueprop>  
  51.       props>  
  52.     property>  
  53.     <property name="eventListeners">  
  54.       <map>  
  55.         <entry key="merge">  
  56.           <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>  
  57.         entry>  
  58.       map>  
  59.     property>  
  60.   bean>  
  61.   <aop:config proxy-target-class="true">  
  62.     <aop:advisor pointcut="execution(* *..Hibernate.*(..))" advice-ref="txAdvice"/>  
  63.   aop:config>  
  64.   <tx:advice id="txAdvice">  
  65.     <tx:attributes>  
  66.       <tx:method name="*" read-only="false"/>  
  67.     tx:attributes>  
  68.   tx:advice>  
  69.   <bean id="transactionManager"  
  70.         class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  71.     <property name="sessionFactory" ref="sessionFactory"/>  
  72.   bean>  
  73.   <bean id="userDao" class="com.daniel.lr.crbt.share.dao.UserDao">  
  74.     <property name="sessionFactory" ref="sessionFactory"/>  
  75.   bean>  
  76.   <bean id="userDaoProxy"  
  77.         class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
  78.     <property name="transactionManager" ref="transactionManager" />  
  79.     <property name="target" ref="userDao"/>  
  80.     <property name="transactionAttributeSource">  
  81.       <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>  
  82.     property>  
  83.   bean>  
  84.   <bean name="/login"  
  85.         class="com.daniel.lr.crbt.service.web.action.LoginAction"  
  86.         scope="prototype">  
  87.     <property name="userDao" ref="userDao"/>  
  88.   bean>  
  89. beans>