Spring xml设置

来源:互联网 发布:c语言下载官方下载 编辑:程序博客网 时间:2024/06/03 02:44

<!-- 确保可在@Value中, 使用SeEL表达式获取资源属性 --><bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">   <property name="properties" ref="configProperties" /></bean><bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">   <property name="locations">      <list>         <value>classpath*:*.properties</value>      </list>   </property></bean>

用于自动读取如/test/resources/config/下的properties文件。

<context:component-scan base-package="com.baidu.fbu.fcore.accounting.loan" /><context:component-scan base-package="com.baidu.fbu.fcore.accounting" /><context:component-scan base-package="com.baidu.fbu.fcore.common" /><context:component-scan base-package="com.baidu.fbu.fcore.common.daycut" />

用于开启annotation自动扫描。

<!-- Imports --><import resource="classpath:META-INF/spring/accg-spring-mybatis.xml" /><import resource="classpath:META-INF/spring/accg-spring-cache.xml" /><import resource="classpath:META-INF/spring/accg-spring-jobs.xml" />

import其他xml配置文件。



cache.xml

<!-- Enable spring AOP --><aop:aspectj-autoproxy />

开启AOP。可以使用@AspectJ配置。


<!-- Cache key generator --><bean id="keyGenerator" class="com.baidu.fbu.fcore.common.cache.SignatureKeyGenerator" />

引入外部类的bean容器。


<!-- Cache manager --><cache:annotation-driven/><bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">   <property name="caches">      <set>         <bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"              p:name="${accg.cache.name}" p:allowNullValues="false" />         <bean class="com.baidu.fbu.fcore.common.cache.RedisCache">            <property name="name" value="${daycut.cache.name}" />            <property name="ttl" value="${daycut.cache.ttl}"></property>         </bean>      </set>   </property></bean>

引入cache部分,启用注解开启cache。















0 0
原创粉丝点击