spring中排除某個類


在spring中可能需要排除某個類,做法是在spring配置文件中加入如下配置

<context:component-scan base-package="com.ias" use-default-filters="false">
        <context:exclude-filter type="assignable" expression="com.ias.agdis.terminal.rest.impl.endpoint.SecurityEndpointImpl"/> 
</context:component-scan>

配置效果如下圖所示:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://camel.apache.org/schema/spring
            http://camel.apache.org/schema/spring/camel-spring-2.16.1.xsd">

    <context:component-scan base-package="com.ias" use-default-filters="false">
        <context:exclude-filter type="assignable" expression="com.ias.agdis.terminal.rest.impl.endpoint.SecurityEndpointImpl"/> 
    </context:component-scan>
    
    <!-- 將配置文件讀取到容器中,交給Spring管理 -->
    <bean id="configProperties"
        class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:jdbc_mysql.properties</value>
                <value>classpath:config.properties</value>
            </list>
        </property>
        <!-- 設置編碼格式 -->
        <property name="fileEncoding" value="UTF-8"></property>
    </bean>
    <!-- 將多個配置文件位置放到列表中 -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">  
        <property name="properties" ref="configProperties" />  
    </bean>  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM