Advertisement

Spring注解详解:@ComponentScan用于自动扫描组件使用

阅读量:

目录

无注解方式component-scan使用

注解方式@ComponentScan使用

@ComponentScan的扫描规则


无注解方式component-scan使用

之前,我们需要扫描工程下一些类上所标注的注解,这些常用注解有:

@Controller,@Service,@Component,@Repository

为了在Spring的配置文件中详细配置context:component-scan执行扫描操作以处理这些特定注解的形式

复制代码
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.sprin

全部评论 (0)

还没有任何评论哟~