2016-06-28 44 views
1

我想重载Springs CommonAnnotationBeanPostProcessor与自定义类(CustomCommonAnnotationBeanPostProcessor),它扩展了CommonAnnotationBeanPostProcessor。如何通过自定义预处理器覆盖CommonAnnotationBeanPostProcessor

我从文档中看到有可能这样做,但我不知道如何去做。

注意:默认的CommonAnnotationBeanPostProcessor将由“context:annotation-config”和“context:component-scan”XML标签进行注册。如果您打算指定自定义的CommonAnnotationBeanPostProcessor bean定义,请在那里删除或关闭默认的注释配置!

以前有人做过这个吗?

回答

1

看后续样品:

<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" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:property-placeholder location="classpath:test.properties"/> 

    <bean class="br.org.energia.csi.scl.batch.spring.configuration.NSCLAnnotationBeanPostProcessor" /> 
    <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> 
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> 
    <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" /> 

    <context:component-scan annotation-config="false" base-package="br.org.energia.test"> 
     <context:include-filter type="annotation" expression="javax.ejb.Stateless" /> 
    </context:component-scan> 

该关闭CommonAnnotationBeanPostProcessor会属性为 “注解的配置= '假'”。但是当你这样做时,你需要配置你需要的PostProcessors。