Spring中配置文件applicationContext.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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd"
default-lazy-init="true">
<!-- PropertyPlaceholderConfigurer实现了BeanFactoryPostProcessor接口,它能够对<bean/>中的属性值进行外在化管理。开发者可以提供单独的属性文件来管理相关属性。-->
<context:property-placeholder location="classpath*:/shopxx.properties" ignore-resource-not-found="true" ignore-unresolvable="true" />
<!-- 自动加载bean-->
<context:component-scan base-package="net.shopxx">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!--C3P0是一个开放源代码的JDBC连接池,它在lib目录中与Hibernate一起发布,包括了实现jdbc3和jdbc2扩展规范说明的Connection 和Statement 池的DataSources 对象。-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize" value="${connection_pools.initial_pool_size}" />
<property name="minPoolSize" value="${connection_pools.min_pool_size}" />
<property name="maxPoolSize" value="${connection_pools.max_pool_size}" />
<property name="maxIdleTime" value="${connection_pools.max_idle_time}" />
<property name="acquireIncrement" value="${connection_pools.acquire_increment}" />
<property name="checkoutTimeout" value="${connection_pools.checkout_timeout}" />
</bean>
<!--jpa持久化-->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceXmlLocation" value="classpath*:/persistence.xml" />
<property name="persistenceUnitName" value="persistenceUnit" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="true" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
<prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.connection.isolation">3</prop>
<prop key="javax.persistence.validation.mode">none</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
<prop key="hibernate.search.default.indexBase">${java.io.tmpdir}/${system.project_name}/index</prop>
</props>
</property>
</bean>
<!--通过@Transactional注解就可以引入事务管理功能。-->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<cache:annotation-driven cache-manager="cacheManager" />
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="setProperty" />
<property name="arguments">
<list>
<value>system.project_name</value>
<value>${system.project_name}</value>
</list>
</property>
</bean>
<!--缓存配置-->
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:/ehcache.xml" />
<property name="shared" value="true" />
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehCacheManager" />
</bean>
<bean id="freeMarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPaths" value="${template.loader_path}" />
<property name="freemarkerSettings">
<props>
<prop key="defaultEncoding">${template.encoding}</prop>
<prop key="url_escaping_charset">${url_escaping_charset}</prop>
<prop key="locale">${locale}</prop>
<prop key="template_update_delay">${template.update_delay}</prop>
<prop key="tag_syntax">auto_detect</prop>
<prop key="whitespace_stripping">true</prop>
<prop key="classic_compatible">true</prop>
<prop key="number_format">${template.number_format}</prop>
<prop key="boolean_format">${template.boolean_format}</prop>
<prop key="datetime_format">${template.datetime_format}</prop>
<prop key="date_format">${template.date_format}</prop>
<prop key="time_format">${template.time_format}</prop>
<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="systemName" value="${system.name}" />
<entry key="systemVersion" value="${system.version}" />
<entry key="systemDescription" value="${system.description}" />
<entry key="systemShowPowered" value="${system.show_powered}" />
<entry key="base" value="#{servletContext.contextPath}" />
<entry key="locale" value="${locale}" />
<entry key="setting" value="#{T(net.shopxx.util.SettingUtils).get()}" />
<entry key="message" value-ref="messageMethod" />
<entry key="abbreviate" value-ref="abbreviateMethod" />
<entry key="currency" value-ref="currencyMethod" />
<entry key="execute_time" value-ref="executeTimeDirective" />
<entry key="flash_message" value-ref="flashMessageDirective" />
<entry key="pagination" value-ref="paginationDirective" />
<entry key="seo" value-ref="seoDirective" />
<entry key="ad_position" value-ref="adPositionDirective" />
<entry key="member_attribute_list" value-ref="memberAttributeListDirective" />
<entry key="navigation_list" value-ref="navigationListDirective" />
<entry key="tag_list" value-ref="tagListDirective" />
<entry key="friend_link_list" value-ref="friendLinkListDirective" />
<entry key="brand_list" value-ref="brandListDirective" />
<entry key="article_list" value-ref="articleListDirective" />
<entry key="article_category_root_list" value-ref="articleCategoryRootListDirective" />
<entry key="article_category_parent_list" value-ref="articleCategoryParentListDirective" />
<entry key="article_category_children_list" value-ref="articleCategoryChildrenListDirective" />
<entry key="product_list" value-ref="productListDirective" />
<entry key="product_category_root_list" value-ref="productCategoryRootListDirective" />
<entry key="product_category_parent_list" value-ref="productCategoryParentListDirective" />
<entry key="product_category_children_list" value-ref="productCategoryChildrenListDirective" />
<entry key="review_list" value-ref="reviewListDirective" />
<entry key="consultation_list" value-ref="consultationListDirective" />
<entry key="promotion_list" value-ref="promotionListDirective" />
</map>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="cacheSeconds" value="${message.cache_seconds}" />
<property name="useCodeAsDefaultMessage" value="true" />
<property name="basenames">
<list>
<value>${message.common_path}</value>
<value>${message.shop_path}</value>
<value>${message.admin_path}</value>
</list>
</property>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
<property name="defaultLocale" value="${locale}" />
</bean>
<bean id="imageCaptchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService">
<property name="captchaEngine">
<bean class="net.shopxx.CaptchaEngine" />
</property>
<property name="minGuarantedStorageDelayInSeconds" value="3600" />
</bean>
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
<!--
<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
-->
</props>
</property>
</bean>
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="${task.core_pool_size}" />
<property name="maxPoolSize" value="${task.max_pool_size}" />
<property name="queueCapacity" value="${task.queue_capacity}" />
<property name="keepAliveSeconds" value="${task.keep_alive_seconds}" />
</bean>
<!-- 这句是定时器开关-->
<task:annotation-driven />
</beans>
Spring中配置文件applicationContext.xml配置详解的更多相关文章
- Spring的配置文件ApplicationContext.xml配置头文件解析
Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applica ...
- Tomcat中的Server.xml配置详解
Tomcat中的Server.xml配置详解 Tomcat Server的结构图如下: 该文件描述了如何启动Tomcat Server <Server> <Listener /> ...
- Spring MVC的web.xml配置详解(转)
出处http://blog.csdn.net/u010796790 1.spring 框架解决字符串编码问题:过滤器 CharacterEncodingFilter(filter-name) 2.在w ...
- Spring mvc的web.xml配置详解
1.spring 框架解决字符串编码问题:过滤器 CharacterEncodingFilter(filter-name) 2.在web.xml配置监听器ContextLoaderListener(l ...
- 1、Spring MVC的web.xml配置详解(转)
版权声明:本文为博主原创文章,转载请注明出处http://blog.csdn.net/u010796790 1.spring 框架解决字符串编码问题:过滤器 CharacterEncodingFilt ...
- Spring MVC 配置文件dispatcher-servlet.xml 文件详解
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Spring MVC 配置文件dispatcher-servlet.xml 文件详解(转自 学无止境-yj)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- 关于hbase中的hbase-site.xml 配置详解
该文档是用Hbase默认配置文件生成的,文件源是 hbase-default.xml hbase.rootdir 这个目录是region server的共享目录,用来持久化HBase.URL需要是'完 ...
- Spring 入门 web.xml配置详解
Spring 入门 web.xml配置详解 https://www.cnblogs.com/cczz_11/p/4363314.html https://blog.csdn.net/hellolove ...
随机推荐
- python知识总结
LIST:Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素,用[]包裹.例如 classmates = ['Michael', 'Bob', 'T ...
- (11)lambda表达式用法
* lambda 简述 lambda只是一个表达式,函数体比def简单很多 lambda的主体是一个表达式,而不是一个代码块.仅仅能在lambda表达式中封装有限的逻辑进去. lam ...
- WIN7下更改TFS连接用户的方法
如果你在第一用VS连接TFS的时候,当你输入完用户名和密码并点击保存时,你的用户登录信息就保存在Credential Manager. 你可以到 Control Panel->User Acco ...
- 解决qt5在ubuntu下无法调用fcitx输入中文的问题
如题,在以前安装qt5.2.1的时候就遇到了这个问题.当时上网搜了很多资料,结果都解决不了,发现都是复制来复制去. 这次因为要用qt5.3.0在ubuntu下写个程序,所以不解决这个问题不行了.就继续 ...
- influxdb和boltDB简介——底层本质类似LMDB,MVCC+B+树
influxdb influxdb是最新的一个时间序列数据库,最新一两年才产生,但已经拥有极高的人气.influxdb 是用Go写的,0.9版本的influxdb对于之前会有很大的改变,后端存储有Le ...
- FaceBook Twitter实习生简历求内推
写在博客里面吧. 有一个朋友,男,博士在读,研究方向为图像处理,计算机视觉相关. 想在在读期间有一些海外实习经历.不知道哪位博友,有相关的人脉,求内推啊.内推成功的话请吃大餐,哈哈!
- SqlFunctions 可以在EF种调用sqlserver的函数
在EF5环境下,首先添加EF环境,在引用中添加Syste.Data.Entity,再添加命名空间 using System.Data.Objects.SqlClient; 然后写一个控制器测试 pub ...
- [转]z-order引出的问题
在窗口与窗口之间毫无重叠的情况下,根本不需要关心z-order.然而,当窗口之间出现重叠时,系统就需要通过一个标准来确定窗口的显示顺序.这个标准就是z-order.存在多个因素影响一个窗口的z-ord ...
- Jquery.Page.js 分页插件的使用
1.简单直接贴代码 需要引用以下样式和脚本 <link href="~/Scripts/Page/pager.css" rel="stylesheet" ...
- 通过电脑(计算机)下载google play的应用的方法
手机上安装GOOGLE PLAY很麻烦,经常不成功.于是采用电脑下载APK的方法. 网上传说的下载chrome的插件,然后获取DEVICE ID的方法,经过试用,一直无法获得DEVICE ID. 经过 ...