`
taiwei.peng
  • 浏览: 232627 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Spring 配置

    博客分类:
  • java
阅读更多
<?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-2.5.xsd
               http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
               http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
   
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 注解必要的 -->
<context:component-scan base-package="com.soft" />

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="defaultAutoCommit">
<value>false</value>
</property>
</bean>

<bean id="sessionFactory"        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.hbm2ddl.auto">none</prop>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.connection.pool_size">5</prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.use_sql_comments">true</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>

        <property name="packagesToScan">
            <list>
                <value>com.soft.nvsg.platform.model</value>
            </list>
        </property>
    </bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
  <property name="sessionFactory" ref="sessionFactory" />
</bean>

<!--事物开始-->
    <bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>   
   
    <tx:advice id="serviceAdvice" transaction-manager="transactionManager">
    <tx:attributes> 
        <tx:method name="add*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="save*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="batchUpdate*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="submit*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="export*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="generate*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="deploy*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="start*" propagation="REQUIRED" rollback-for="Throwable"/>
        <tx:method name="*" read-only="true"/>
    </tx:attributes>
    </tx:advice>
   
    <aop:config proxy-target-class="true">
       <aop:pointcut id="servicePointcut" expression="execution(* com.soft.nvsg.platform.service.impl.*.*(..))"/>
       <aop:advisor pointcut-ref="servicePointcut" advice-ref="serviceAdvice"  order="1"/>
    </aop:config>        
<!--事物结束-->
</beans>      
分享到:
评论

相关推荐

    Spring配置加注释

    Spring配置 Spring 配置 映射 加注释!!!!Spring配置 Spring 配置 映射 加注释!!!!

    spring配置文件加密实现

    为了保护这些敏感信息不被非法访问或篡改,我们可以对Spring配置文件进行加密处理。本文将深入探讨如何在Java环境中,利用TE网络技术实现Spring配置文件的加密。 首先,我们需要理解Spring配置文件的基本结构。...

    spring配置文件实例

    spring配置文件实例

    spring配置文件详解

    Spring 配置文件详解 Spring 配置文件是 Spring 框架中最重要的配置文件之一,它负责定义和配置应用程序的Bean对象,以及它们之间的依赖关系。Spring 配置文件通常以XML文件的形式存在,文件名通常为...

    spring配置 spring配置 spring配置 spring配置 spring配置

    spring配置 spring配置 spring配置 spring配置 spring配置

    ssm配置spring配置

    ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssm...

    MyBatis-Spring配置教程,非常适合初学者

    【MyBatis-Spring配置教程】是一份专为初学者设计的教程,旨在帮助学习者快速掌握如何在Spring框架中整合并使用MyBatis。MyBatis是一个优秀的持久层框架,它支持定制化SQL、存储过程以及高级映射,而Spring则是一个...

    Spring配置MySQL数据源

    连接MYSQL数据库,SPRING配置文件示例。

    spring配置文件详解,每一步都含有注释

    spring配置文件详解,交你如何理解spring,熟练运用spring

    spring配置步骤

    ### Spring配置步骤详解 #### 一、Spring框架简介 Spring框架是Java平台上的一个开源框架,它提供了一种简化企业级应用开发的方式。Spring的核心功能包括依赖注入(Dependency Injection, DI)、面向切面编程...

    spring配置文件

    spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件...

    spring配置的简单案例.zip

    spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip spring配置的简单案例.zip ...

    Spring的基本配置

    一、Spring配置概述 Spring的配置方式主要有两种:XML配置和Java配置。早期,XML配置是主流,而现在,随着Spring Boot的兴起,Java配置逐渐成为首选,因为它更加简洁和直观。不过,理解XML配置对于学习Spring的基础...

    spring配置文件详细介绍

    下面是对Spring配置文件的详细介绍。 首先,Spring配置文件通常是以`.xml`为扩展名的文件,例如`beans.xml`。这些文件存储在项目的`src/main/resources`目录下,以便在运行时被自动加载。Spring容器...

    Spring配置文件集合

    在本压缩包中,我们找到了一系列与Spring相关的配置文件,这些文件在构建JavaWeb应用时起着至关重要的作用。 1. `jdbc.properties`: 这个文件通常用于存储数据库连接的相关信息,如URL、用户名、密码等。它是Spring...

    xbean简化spring配置文件.doc

    xbean简化spring配置文件 xbean是 Apache Geronimo 项目的一个子项目,旨在简化Spring配置文件的编写。下面我们来详细介绍如何使用xbean简化Spring配置文件。 在Spring之前,我们使用Factory模式来管理bean。例如...

    spring配置全书.doc

    《Spring配置全书》深入解析 Spring框架是Java企业级开发的重要工具,它引入了松耦合的配置和对象组装方式,使得应用的构建变得更加简洁高效。依赖注入作为Spring容器的核心功能,彻底改变了传统Java应用中对象之间...

    如何加载jar包中的spring配置文件

    在Spring MVC项目中,加载jar包中的Spring配置文件是一个常见的需求,特别是在进行SSM(Spring、Spring MVC、MyBatis)整合时。SSM框架的整合通常涉及到多个配置文件的组织和管理,其中一部分配置可能会被打包到独立...

Global site tag (gtag.js) - Google Analytics