<?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"
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/beans/spring-context.xsd">
<!--use-default-filters="false" 代表不使用默认的过滤器扫描指定的包,默认过滤器会扫描所有带注释类-->
<!-- <context:component-scan base-package="com.zjx.bean" use-default-filters="false">-->
<!--只扫描带有Component注释的类-->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Component"/>-->
<!-- </context:component-scan>-->
<!--当不设置自定义的过滤器时可以指定不扫描对象-->
<context:component-scan base-package="com.zjx.bean">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Component"/>
</context:component-scan>
</beans>
spring组件扫描配置(设置过滤器)
最新推荐文章于 2025-06-01 11:59:28 发布
本文介绍了Spring Boot中如何配置组件扫描,通过XML配置展示了如何排除特定注解的类,以便精细化控制扫描过程。理解这一配置有助于优化应用启动时间和资源利用率。
2016

被折叠的 条评论
为什么被折叠?



