使用@ComponentScan扫描策略

package com.springboot.chapter3.config;

import com.springboot.chapter3.pojo.User;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/*@Configuration代表这是一个Java配置文件,Spring的容器会根据它来生成IoC容器去装配Bean*/
@Configuration
@ComponentScan("com.springboot.chapter3.*") //定义扫描的包
/*@ComponentScan(basePackages = {"com.springboot.chapter3.pojo"})定义扫描的包
  @ComponentScan(basePackages = {"com.springboot.chapter3.*"},excludeFilters = {@ComponentScan.Filter(classes =
        {Service.class})}) 定义扫描的包,并设置过滤条件
@ComponentScan(basePackageClasses = {User.class})定义扫描的类*/
public class AppConfig {

}
posted @ 2020-04-11 10:03  xl4ng  阅读(650)  评论(0编辑  收藏  举报