applicationContext.xml配置介绍
来源:互联网 发布:js加密 java解密 编辑:程序博客网 时间:2024/06/08 16:14
<beans <!-- beans是xml文件的根节点 -->
xmlns="http://www.springframework.org/schema/beans" <!-- xmlns是XML NameSpace的缩写,因为XML文件的标签名称都是自定义的,自己写的和其他人定义的标签很有可能会重复命名,而功能却不一样,所以需要加上一个namespace来区分这个xml文件和其他的xml文件,类似于java中的package -->
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <!-- xsi是指xml文件遵守xml规范,xsi全名:xml schema 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"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation=" <!--xsi:schemaLocation——是指具体用到的schema资源(不要看相关中文资料,看了就不明白了,schema就是schema~你把他翻译成对文档的限制就行了。你可能会说,dtd才是,实际上xsd和dtd是一样的-->
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
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-4.0.xsd ">
<!-- 加载数据库属性配置文件 -->
<context:property-placeholder location="classpath:/properties/db.properties" />
<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:/properties/application.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>
<!-- 数据库配置 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="alias" value="defaultsDB" />
<property name="driver" value="${jdbc.driver}" />
<property name="driverUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.name}" />
<property name="password" value="${jdbc.password}" />
<property name="prototypeCount" value="5" />
<property name="maximumConnectionCount" value="50" />
<property name="minimumConnectionCount" value="5" />
<property name="maximumActiveTime" value="900000" />
<property name="trace" value="true" />
<property name="verbose" value="true" />
</bean>
<!-- session工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configLocation" value="classpath:xml/hibernate.cfg.xml"/>
<!-- 自动扫描注解方式配置的hibernate类文件 -->
<property name="packagesToScan">
<list>
<value>com.douwong.entity</value>
</list>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 普通类调用Spring bean对象 -->
<bean id="springTool" class="com.douwong.common.SpringTool"></bean>
<!-- JDBC -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
scope="prototype">
<property name="dataSource" ref="dataSource" />
</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="del*" propagation="REQUIRED" />
<tx:method name="send*" propagation="REQUIRED" />
<tx:method name="clear*" propagation="REQUIRED" />
<tx:method name="change*" propagation="REQUIRED" />
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 应用普通类获取bean
<bean id="appContext" class="com.soanl.util.tool.ApplicationUtil"/>-->
<!-- 配置ehcache缓存 -->
<cache:annotation-driven cache-manager="cacheManager"/><!-- 启用缓存注解开关 -->
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:xml/ehcache.xml"/>
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcacheManager"/>
<property name="transactionAware" value="true"/>
</bean>
<!-- 配置事务切面 -->
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(* com.douwong.manage.*.service..*.*(..)) ||execution(* com.douwong.manage.*.dao..*.*(..))||execution(* com.douwong.core.dao..*.*(..))||execution(* com.douwong.core.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config>
<!-- 配置扫描路径 -->
<context:component-scan base-package="com.douwong">
<!-- 只扫描Service,也可以添加Repostory,但是要把Controller排除在外,Controller由spring-mvc.xml去加载 -->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
ehcache.xml配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="./target/tmp"/><!-- 磁盘缓存位置 -->
<defaultCache <!-- 默认缓存参数 -->
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
/>
<cache name="sampleCache1"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
/>
<cache name="sampleCache2"
maxElementsInMemory="1000"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>
<!-- 扫码登录等时间极短的缓存,时间为70秒 -->
<cache name="scanCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="30"
timeToLiveSeconds="70"
overflowToDisk="true"
/>
</ehcache>
- applicationContext.xml配置介绍
- applicationContext.xml配置
- applicationContext.xml 配置说明
- applicationContext.xml配置分析
- struts2-applicationContext.xml配置
- applicationContext.xml 配置模板
- applicationContext.xml 配置说明
- applicationContext.xml 配置说明
- spring applicationContext.xml配置
- applicationContext.xml 配置方法
- applicationContext.xml 配置说明
- 配置applicationcontext.xml文件
- applicationContext.xml 配置说明
- applicationContext.xml配置分析
- applicationContext.xml 配置说明
- applicationContext.xml配置c3p0
- 配置applicationContext.xml
- applicationContext.xml 配置
- "知识图谱在股权投资领域的尝试"读后感
- shiro内置过滤器
- 祝106个护士节快乐—献给白衣天使的你
- RecyclerView的滑动删除以及下拉加载
- Python的import
- applicationContext.xml配置介绍
- NDPI的分析
- MyEclipse JVM内存配置及性能调优
- java遍历完全二叉树
- ORACLE DATABASE 11G RAC 知识图文详细教程之ORACLE集群概念和原理(二)
- 闭包与变量
- 一步一步学习 ReactNative + Redux(0)
- 网易之跑去公司
- pcapReader——源码分析