zoukankan      html  css  js  c++  java
  • OA学习笔记-004-Spring2.5配置

    一、jar包

    (1)spring.jar

    (2)Aop包

    aspectjrt.jar
    aspectjweaver.jar

    (3)动态代理

    cglib-nodep-2.1_3.jar

    (4)日志

    commons-logging.jar


    二、appicationContext.xml/beans.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" xmlns:context="http://www.springframework.org/schema/context"
     4     xmlns:tx="http://www.springframework.org/schema/tx"
     5     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     6                 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
     7                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     8 
     9     <!-- 自动扫描(包含子包)与装配bean以便可以写注解 -->
    10     <context:component-scan base-package="cn.itcast.oa"></context:component-scan>
    11 
    12     
    13     <!-- 导入外部的properties文件 -->
    14     <context:property-placeholder location="classpath:jdbc.properties"/>
    15 
    16 
    17     <!-- 配置SessionFactory -->
    18     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    19         <!-- 指定hibernate的配置文件位置 -->
    20         <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
    21         <!-- 配置c3p0数据库连接池 -->
    22         <property name="dataSource">
    23             <bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
    24                 <!-- 数据连接信息 -->
    25                 <property name="jdbcUrl" value="${jdbcUrl}"></property>
    26                 <property name="driverClass" value="${driverClass}"></property>
    27                 <property name="user" value="${user}"></property>
    28                 <property name="password" value="${password}"></property>
    29                 <!-- 其他配置 -->
    30                 <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
    31                 <property name="initialPoolSize" value="3"></property>
    32                 <!--连接池中保留的最小连接数。Default: 3 -->
    33                 <property name="minPoolSize" value="3"></property>
    34                 <!--连接池中保留的最大连接数。Default: 15 -->
    35                 <property name="maxPoolSize" value="5"></property>
    36                 <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
    37                 <property name="acquireIncrement" value="3"></property>
    38                 <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->
    39                 <property name="maxStatements" value="8"></property>
    40                 <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->
    41                 <property name="maxStatementsPerConnection" value="5"></property>
    42                 <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
    43                 <property name="maxIdleTime" value="1800"></property>
    44             </bean>
    45         </property>
    46     </bean>
    47 
    48 
    49     <!-- 配置声明式事务管理(采用注解的方式) -->
    50     <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    51         <property name="sessionFactory" ref="sessionFactory"></property>
    52     </bean>
    53     <tx:annotation-driven transaction-manager="txManager"/>
    54 
    55 
    56 </beans>
  • 相关阅读:
    hdu 2196 树形dp
    codeforces 1A
    [日常摸鱼]bzoj1218[HNOI2003]激光炸弹-二维前缀
    [日常摸鱼]bzoj2724蒲公英-分块
    [日常摸鱼]关于离散化
    [OI笔记]后缀自动机
    [日常摸鱼]poj1509Glass Beads-SAM
    [日常摸鱼]bzoj1083[SCOI2005]繁忙的都市-最小生成树
    [日常摸鱼]bzoj2038[2009国家集训队]小Z的袜子-莫队算法
    [日常摸鱼]三分法
  • 原文地址:https://www.cnblogs.com/shamgod/p/5225172.html
Copyright © 2011-2022 走看看