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"
<1--任务调度-->
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.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!-- xmls译为xml命名空间-->
<!--加载配置文件-->
<bean id="propertyConfig" class="xxx.xx.propertyConfig">
<property name="locations">
<list>
<!--各个配置的值-->
<value>classpath*:application.properties</value>
<value>classpath*:cache.properties</value>
<value>classpath*:queue.properties</value>
<value>classpath*:log4j.properties</value>
</list>
</property>
<!--数据库加密-->
<property name="xxxpropertiesPersister">
<bean class="xxx.xx.xx.filter.xxxPropertiesPersist" />
</property>
</bean>
<!-- 任务调度器 -->
<task:scheduler id="scheduler" pool-size="" />
<!-- 任务执行器 -->
<task:executor id="executor" pool-size="" />
<!--开启注解调度支持-->
<task:annotation-driven executor="executor"
scheduler="scheduler" proxy-target-class="true" />
<!--开启对注解的支持-->
<context:anotation-config/>
<!--开启包扫描 将统一管理Bean-->
<context:component-scan bask-package="xxx.xx.对应各个层级的位置*">
<context:include-filter type="annotation" expression="xxx.xxx.xxx.service/component/Repository" >
</context:componet-scan>
</beans>
applicationContext-departion.xml
<!--depation-aop-->
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!--定义目标类(需要简化的公共类)-->
<bean id="dao" class="xxx.xxx.xxx.Dao"/>
<bean id="service" class="xxx.xxx.xxx.Service" init-method="initialize">
<property name="dao" ref="dao"></property>
</bean>
<!--定义切面类(抽取出来的公共方法。)-->
<bean id="targetClass_A" class="xxx.xxx.xxx.TargetClass_A"/>
<bean id="targetClass_B" class="xxx.xxx.xxx.TargetClass_B"/>
<bean id="targetClass_C" class="xxx.xxx.xxx.TargetClass_C"/>
<!--aop编程开启注解支持-->
<aop:aspectj-***/>
<!--aop配置-->
<aop:config>
<!--注解类切面-->
<aop:aspect id="aspect_a" ref="targetClass_A">
<!--注解切点-->
<aop:pointcut id="pointcut_a" expression="@annotation(annotation_a)"/>
<!--切点切入时机(有五种类型,此次是取环绕型切点)-->
<aop:around pointcut-ref="pointcut_a" method="detailMethod"/>
</aop:aspect>
<!--日志类切面-->
<aop:aspect id="aspect_a" ref="targetClass_A">
<!--注解切点-->
<aop:pointcut id="pointcut_a" expression="@annotation(annotation_a)"/>
<!--切点切入时机(有五种类型,此次是取环绕型切点)-->
<aop:around pointcut-ref="pointcut_a" method="detailMethod"/>
</aop:aspect>
</aop:config>
</bean>