本文主要是介绍spring 3.0 application-conext.xml配置 .,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
这是我开发常用的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:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- <!-- 数据库配置 -->
- <context:property-placeholder location="WEB-INF/mysql.properties, WEB-INF/bonecp.properties"/>
- <!-- 激活@Required 和 @Autowired注解功能 -->
- <context:annotation-config/>
- <!-- 加载中文字符串转拼音的bean -->
- <!-- bean id="cnToSpell" class="com.boaotech.util.CnToSpell" / -->
- <!-- 缓存配置 -->
- <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
- p:configLocation="WEB-INF/ehcache.xml" p:shared="true"/>
- <!-- 数据库源配置 -->
- <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"
- p:driverClass="${jdbc.driverClassName}"
- p:jdbcUrl="${jdbc.url}"
- p:username="${jdbc.username}"
- p:password="${jdbc.password}"
- p:idleConnectionTestPeriod="${bonecp.idleConnectionTestPeriod}"
- p:idleMaxAge="${bonecp.idleMaxAge}"
- p:partitionCount="${bonecp.partitionCount}"
- p:minConnectionsPerPartition="${bonecp.minConnectionsPerPartition}"
- p:maxConnectionsPerPartition="${bonecp.maxConnectionsPerPartition}"
- p:acquireIncrement="${bonecp.acquireIncrement}"
- p:poolAvailabilityThreshold="${bonecp.poolAvailabilityThreshold}"
- p:connectionTimeout="${bonecp.connectionTimeout}"
- p:statementsCacheSize="${bonecp.statementsCacheSize}"
- p:releaseHelperThreads="${bonecp.releaseHelperThreads}"
- p:statementReleaseHelperThreads="${bonecp.statementReleaseHelperThreads}"
- p:disableJMX="true" />
- <!-- 使用iBatis作为持久层 -->
- <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"
- p:configLocation="WEB-INF/sqlmap-config.xml"
- p:dataSource-ref="dataSource"/>
- <!-- 声明事务管理bean -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
- p:dataSource-ref="dataSource" />
- <!-- 激活@Transactional 和 @ManagedOperation 注解,事物管理功能 -->
- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
- </beans>
这篇关于spring 3.0 application-conext.xml配置 .的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!