常用配置文件

spring 配置:

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        ">

	<context:property-placeholder location="classpath:jdbc.properties" />
	
	<context:component-scan base-package="com.dt.basedao"></context:component-scan>
	<context:component-scan base-package="com.dt.dao"></context:component-scan>
	

	<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	
	
	
	<bean id="sessionFactory"	class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="com.dt.bean"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
			</props>
		</property>
	</bean>
	
	<bean id="transactionManager"	class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	
	<tx:annotation-driven transaction-manager="transactionManager" />

	<aop:aspectj-autoproxy proxy-target-class="true" />

</beans>


jdbc 属性文件:
db.name:dt
jdbc.driverClassName:com.mysql.jdbc.Driver
jdbc.url:jdbc:mysql:///${db.name}
jdbc.username:root
jdbc.password:123456
hibernate.dialect:org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto:update
hibernate.format_sql:true
hibernate.show_sql:true




如果是结合druid的话,对应的配置如下:

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        ">

	<!-- http://www.cnblogs.com/yjmyzz/p/4047823.html -->
	<!-- 加载db.properties文件中的内容,db.properties文件中key命名要有一定的特殊规则 -->
	<context:property-placeholder location="classpath:jdbc.properties" />

	<!--3.使用加密版的属性文件 -->
<!-- 	<bean class="com.ye.placeholder.EncryptPropertyPlaceholderConfigurer"
		p:location="classpath:jdbc.properties" p:fileEncoding="utf-8" /> -->

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

	<!-- 数据源配置, 使用 BoneCP 数据库连接池 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
		init-method="init" destroy-method="close">
		<!-- 数据源驱动类可不写,Druid默认会自动根据URL识别DriverClass -->
		<property name="driverClassName" value="${db.driverClassName}" />
		<!-- 基本属性 url、user、password -->
		<property name="url" value="${db.url}" />
		<property name="username" value="${db.username}" />
		<property name="password" value="${db.pwd}" />
		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="3" />
		<property name="minIdle" value="3" />
		<property name="maxActive" value="20" />

		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="60000" />

		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="60000" />

		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="300000" />

		<property name="validationQuery" value="SELECT 'x'" />
		<property name="testWhileIdle" value="true" />
		<property name="testOnBorrow" value="false" />
		<property name="testOnReturn" value="false" />

		<!-- 打开PSCache,并且指定每个连接上PSCache的大小(Oracle使用) <property name="poolPreparedStatements" 
			value="true" /> <property name="maxPoolPreparedStatementPerConnectionSize" 
			value="20" /> -->

		<!-- 配置监控统计拦截的filters -->
		<property name="filters" value="stat" />
	</bean>


	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="com.ye.hiber"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
			</props>
		</property>
	</bean>



	
	
	<!--事务管理器 -->
	<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"
		p:sessionFactory-ref="sessionFactory" />
		
	<!-- <bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean> -->

	<!-- 针对注解声明式的事物 -->
	<tx:annotation-driven transaction-manager="txManager" />


	<!-- 配置数据源,dbcp -->
	<!-- <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean> -->


	<!-- http://blog.csdn.net/yipanbo/article/details/45644751 -->
	<!-- http://www.cnblogs.com/HigginCui/p/5859788.html -->
	<!-- sqlSessionFactory -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 数据库连接池 -->
		<property name="dataSource" ref="dataSource" />
		<!-- 加载mybatis的全局配置文件 -->
		<property name="mapperLocations" value="classpath:/com/ye/mapper/*.xml" />
		<property name="typeAliasesPackage" value="com.ye.bean"></property>
	</bean>

	<!-- mapper扫描器 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 扫描包路径,如果需要扫描多个包,中间使用半角逗号隔开 -->
		<property name="basePackage" value="com.ye.dao"></property>
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>
	
	
	<aop:aspectj-autoproxy proxy-target-class="true" />
</beans>



对应Web.xml的配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>sz</display-name>
 
 
 
 
 <filter>
        <filter-name>DruidWebStatFilter</filter-name>
        <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>DruidWebStatFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
 
    <!-- druid监控 -->
    <servlet>
        <servlet-name>DruidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>DruidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>
 
 
 
 
 <!-- Spring和mybatis的配置文件 -->  
    <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath:app.xml</param-value>  
    </context-param>  
    <!-- 编码过滤器 -->  
    <filter>  
        <filter-name>encodingFilter</filter-name>  
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
        <async-supported>true</async-supported>  
        <init-param>  
            <param-name>encoding</param-name>  
            <param-value>UTF-8</param-value>  
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>encodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
    <!-- Spring监听器 -->  
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
    </listener>  
    <!-- 防止Spring内存溢出监听器 -->  
   <!--  <listener>  
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>  
    </listener>   -->
  
    <!-- Spring MVC servlet -->  
    <servlet>  
        <servlet-name>SpringMVC</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <init-param>  
            <param-name>namespace</param-name>  
            <param-value>sz</param-value>  
        </init-param>  
        <load-on-startup>1</load-on-startup>  
        <async-supported>true</async-supported>  
    </servlet>  
    <servlet-mapping>  
        <servlet-name>SpringMVC</servlet-name>  
        <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 -->  
        <url-pattern>/</url-pattern>  
    </servlet-mapping>  
    
    
    <filter>
		<filter-name>hibernateFilter</filter-name>
		<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>hibernateFilter</filter-name>
		<url-pattern>*.jsp</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>hibernateFilter</filter-name>
		<url-pattern>*.html</url-pattern>
	</filter-mapping>
    
    
    <welcome-file-list>  
        <welcome-file>/index.jsp</welcome-file>  
    </welcome-file-list>  
</web-app>

spring mvc配置文件:


<?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:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        ">


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

	<mvc:annotation-driven />
	
 	<bean id="rpe" class="com.ye.path.ResourcePathExposer" init-method="init"/> 
    <mvc:resources mapping="#{rpe.resourceRoot}/**" location="/" cache-period="31536000"/>  
	<mvc:default-servlet-handler />

	<!-- 定义跳转的文件的前后缀 ,视图模式配置 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>

	<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->
	<!-- http://blog.csdn.net/swingpyzf/article/details/20230865 -->
	<!-- https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=spring%20mvc%E6%8C%87%E5%AE%9A%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6&rsv_pq=e4ef3d190001cbec&rsv_t=200eQrY%2F9a8FDzWaBCXedP1a8372gxmBIQBrIrcRWbcNPSd4mW1lAx0da2Q&rqlang=cn&rsv_enter=1&rsv_sug3=19&rsv_sug1=17&rsv_sug7=100 -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- 默认编码 -->
		<property name="defaultEncoding" value="utf-8" />
		<!-- 文件大小最大值 -->
		<property name="maxUploadSize" value="10485760000" />
		<!-- 内存中的最大值 -->
		<property name="maxInMemorySize" value="40960" />
		<property name="uploadTempDir" value="/temp"></property>
	</bean>
</beans>


log4j配置文件:

log4j.rootLogger=DEBUG, stdout,spring,mybatis
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n


log4j.logger.org.springframework=WARN
log4j.logger.org.hibernate=debug
log4j.appender.spring=org.apache.log4j.ConsoleAppender
log4j.appender.spring.Target=System.out
log4j.appender.spring.layout=org.apache.log4j.PatternLayout
log4j.appender.spring.layout.ConversionPattern=%d %5p (%c:%L) - %m%n

log4j.logger.org.hibernate=debug
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n

log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.Java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.appender.mybatis=org.apache.log4j.ConsoleAppender
log4j.appender.mybatis.Target=System.out
log4j.appender.mybatis.layout=org.apache.log4j.PatternLayout
log4j.appender.mybatis.layout.ConversionPattern=%d %5p (%c:%L) - %m%n



spring和quartzt结合配置:


<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.open-open.com/lib/view/open1423663054857.html -->
<!-- 启动触发器的配置开始  --> 
    <bean name="startQuertz" lazy-init="false" autowire="no"  
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
        <property name="triggers">  
            <list>  
                <ref bean="myJobTrigger" />  
            </list>  
        </property>  
    </bean>  
    <!-- 启动触发器的配置结束 -->  
  
    <!-- 调度的配置开始 -->  
  
    <!-- quartz-2.x的配置   -->
    <bean id="myJobTrigger"  
        class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">  
        <property name="jobDetail">  
            <ref bean="myJobDetail" />  
        </property>  
        <property name="cronExpression">  
            <value>0 0 1 * * ?</value>  
        </property>  
    </bean>   
    <!-- 调度的配置结束 -->  
  
    <!-- job的配置开始   --> 
    <bean id="myJobDetail"  
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
        <property name="targetObject">  
            <ref bean="myJob" />  
        </property>  
        <property name="targetMethod">  
            <value>work</value>  
        </property>  
        <property name="concurrent">
        	<value>false</value>
        </property>
    </bean>  
    <!-- job的配置结束 -->  
  
    <!-- 工作的bean  --> 
    <bean id="myJob" class="com.gwssi.datacenter.quartz.MyJob" /> 


spring和mybatis 结合的部分【来源于http://www.tuicool.com/articles/32u2I3i】:

可选的配置:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <!-- 别名 -->
    <typeAliases>
        <package name="com.java.entity" />    <!-- 后面书写类全名时默认加该包名前缀如:<resultMap type="User"... -->
    </typeAliases>

</configuration>


spring配置文件:

<?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:aop="http://www.springframework.org/schema/aop"   
	xmlns:context="http://www.springframework.org/schema/context"  
	xmlns:jee="http://www.springframework.org/schema/jee"  
	xmlns:tx="http://www.springframework.org/schema/tx"  
	xsi:schemaLocation="	
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd  
		http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd  
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">	
	<!-- 自动扫描该包下面的bean文件 -->
	<context:component-scan base-package="com.java.service"></context:component-scan>
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<!-- <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> -->
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url" value="jdbc:mysql://localhost:3306/crm"/>
		<property name="username" value="root"/>
		<property name="password" value="root"/>
	</bean>
	<!-- 配置MyBatis的sqlSessionFactory -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="configLocation" value="classpath:mybatis-config.xml"></property>		
		<property name="mapperLocations" value="classpath:com/java/mappers/*.xml"></property>
	</bean>
	<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper  -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.java.dao"></property>
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>
	<!-- 配置transactionManager事务管理器 -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	<!-- 配置事物通知属性 -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<!-- 定义事物传播特性 -->
		<tx:attributes>
			<tx:method name="insert" propagation="REQUIRED"/>
			<tx:method name="update*" propagation="REQUIRED" />  
			<tx:method name="edit*" propagation="REQUIRED" />  
			<tx:method name="save*" propagation="REQUIRED" />  
			<tx:method name="add*" propagation="REQUIRED" />  
			<tx:method name="new*" propagation="REQUIRED" />  
			<tx:method name="set*" propagation="REQUIRED" />  
			<tx:method name="remove*" propagation="REQUIRED" />  
			<tx:method name="delete*" propagation="REQUIRED" />  
			<tx:method name="change*" propagation="REQUIRED" />  
			<tx:method name="check*" propagation="REQUIRED" />  
			<tx:method name="get*" propagation="REQUIRED" read-only="true" />  
			<tx:method name="find*" propagation="REQUIRED" read-only="true" />  
			<tx:method name="load*" propagation="REQUIRED" read-only="true" />  
			<tx:method name="*" propagation="REQUIRED" read-only="true" />  
		</tx:attributes>
	</tx:advice>
	<!-- 配置事物切面 -->
	<aop:config>
		<aop:pointcut expression="execution(* com.java.service.*.*(..))" id="serviceOperation"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
	</aop:config>
</beans>

也可以是如下的配置,即去掉mybatis的mybait-config.xml文件【详细看注释】

<?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:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans  
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
                        http://www.springframework.org/schema/context  
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd  
                        http://www.springframework.org/schema/mvc  
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
	<!-- 自动扫描 -->
	<context:component-scan base-package="com.cn.hnust" />
	<!-- 引入配置文件 -->
	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:jdbc.properties" />
	</bean>

	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${driver}" />
		<property name="url" value="${url}" />
		<property name="username" value="${username}" />
		<property name="password" value="${password}" />
		<!-- 初始化连接大小 -->
		<property name="initialSize" value="${initialSize}"></property>
		<!-- 连接池最大数量 -->
		<property name="maxActive" value="${maxActive}"></property>
		<!-- 连接池最大空闲 -->
		<property name="maxIdle" value="${maxIdle}"></property>
		<!-- 连接池最小空闲 -->
		<property name="minIdle" value="${minIdle}"></property>
		<!-- 获取连接最大等待时间 -->
		<property name="maxWait" value="${maxWait}"></property>
	</bean>

	<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- 自动扫描mapping.xml文件 -->
		<property name="mapperLocations" value="classpath:com/cn/hnust/mapping/*.xml"></property>
	</bean>

	<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.cn.hnust.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>

	<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

</beans>
来源于http://blog.csdn.net/zhshulin/article/details/37956105/



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值