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>