zoukankan      html  css  js  c++  java
  • Spring托管Struts2和Hibernate的配置文件

    <?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:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
          xsi:schemaLocation=
          "http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-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/tx
          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    
    
       <context:component-scan base-package="com.zzzy.test" />
       <aop:aspectj-autoproxy proxy-target-class="true"/>
            
            
            <!-- 数据源配置 -->
        <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource">
            <property name="driverClassName"
                value="oracle.jdbc.OracleDriver">
            </property>
            <property name="url"
                value="jdbc:oracle:thin:localhost:1521:orcl">
            </property>
            <property name="username" value="scott"></property>
            <property name="password" value="tiger"></property>
        </bean>
        
        
        <!-- factory 的配置 -->
        <bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource" />
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">
                        org.hibernate.dialect.Oracle9Dialect
                    </prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.format_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                    <!-- 用于生成有助于调试的注释信息,默认为关闭 -->
                    <prop key="hibernate.use_sql_comments">false</prop>
                    
                </props>
            </property>
            
            
                <!-- 扫描使用注解的实体类所在的包,不再使用annotatedClasses参数 -->
            <property name="packagesToScan">
                <list>
                    <value>com.zzzy.test</value>
                </list>
            </property>
        </bean>
        
        
        
        
        <bean id="transcationManager"  
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>    
        </bean>
        
        
        
        <tx:advice  id="txAdvice" transaction-manager="transcationManager">
        <tx:attributes>
        <tx:method name="query*" propagation="REQUIRED" read-only="true"/>
        <tx:method name="add*" propagation="REQUIRED"/>
        <tx:method name="*" read-only="true" />
        </tx:attributes>
        </tx:advice>
        
        
        <aop:config >
        <aop:pointcut  
        id="txMethod" expression="execution(* com.zzzy.test.ServiceDaoImp..*.*(..)) "/>
        
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txMethod" />
        
        </aop:config>
        
        <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
        
        
        </beans>
  • 相关阅读:
    学习路线
    环境搭建时用到的文档
    商城技术重点分析
    svn 忽略文件
    实用的css3 学习笔记
    转载 《AngularJS》5个实例详解Directive(指令)机制
    php 单例设计模式 example
    html5 图片转base64预览显示
    curl返回常见错误码
    jquery的end(),addBack()方法example
  • 原文地址:https://www.cnblogs.com/wjn563/p/4331194.html
Copyright © 2011-2022 走看看