码迷,mamicode.com
首页 > 编程语言 > 详细

spring配置记录笔记

时间:2015-01-19 06:52:30      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:spring配置

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:jdbc="http://www.springframework.org/schema/jdbc"

xmlns:util="http://www.springframework.org/schema/util"

  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/tx 

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 

http://www.springframework.org/schema/jee 

http://www.springframework.org/schema/jee/spring-jee-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/jdbc 

http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd

     http://www.springframework.org/schema/aop 

     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

      http://www.springframework.org/schema/util 

      http://www.springframework.org/schema/util/spring-util-3.0.xsd" 

default-lazy-init="false" default-autowire="byName">


<description>Spring公共配置 </description>

<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->

<context:component-scan base-package="com.my" />

<!--全局配置地址 -->

<!--全局配置地址 -->

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />

<property name="ignoreResourceNotFound" value="true" />

<property name="locations">

<list>

<!-- 标准配置 -->

<value>classpath*:/global.properties</value>

<value>classpath*:/important.properties</value>

</list>

</property>

</bean>

    

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

<property name="driverClassName" value="${jdbc.driver}" />

<property name="url" value="${jdbc.url}" />

<property name="username" value="${jdbc.username}" />

<property name="password" value="${jdbc.password}" />

<property name="maxIdle" value="${dbcp.maxIdle}" />

<property name="maxActive" value="${dbcp.maxActive}" />

<property name="defaultAutoCommit" value="true" />

<property name="timeBetweenEvictionRunsMillis" value="3600000" />

<property name="minEvictableIdleTimeMillis" value="3600000" />

    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource" ref="dataSource" />

    </bean>

     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

        <property name="dataSource" ref="dataSource" />

        <property name="configLocation" value="classpath:mybatis-config.xml" />

        <property name="mapperLocations" value="classpath:/mappers/*.xml" />

    </bean>

    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">

  <constructor-arg index="0" ref="sqlSessionFactory" /> 

    </bean>

    <bean id="safConnectionsDao" class="com.xxx.dao">

    <property name="sqlSession" ref="sqlSession" />

    </bean>


</beans>


spring配置记录笔记

标签:spring配置

原文地址:http://jfzhang.blog.51cto.com/1934093/1605485

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!