首页 > 代码库 > spring配置记录笔记

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="http://www.mamicode.com/SYSTEM_PROPERTIES_MODE_OVERRIDE" />

<property name="ignoreResourceNotFound" value="http://www.mamicode.com/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="http://www.mamicode.com/${jdbc.driver}" />

<property name="url" value="http://www.mamicode.com/${jdbc.url}" />

<property name="username" value="http://www.mamicode.com/${jdbc.username}" />

<property name="password" value="http://www.mamicode.com/${jdbc.password}" />

<property name="maxIdle" value="http://www.mamicode.com/${dbcp.maxIdle}" />

<property name="maxActive" value="http://www.mamicode.com/${dbcp.maxActive}" />

<property name="defaultAutoCommit" value="http://www.mamicode.com/true" />

<property name="timeBetweenEvictionRunsMillis" value="http://www.mamicode.com/3600000" />

<property name="minEvictableIdleTimeMillis" value="http://www.mamicode.com/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="http://www.mamicode.com/classpath:mybatis-config.xml" />

        <property name="mapperLocations" value="http://www.mamicode.com/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配置记录笔记