Spring @Component
@Component
代码样例
定义
@Component 标明哪个类被扫描进入Spring IoC容器
配置的user作为Bean名称,否则默认类名且令第一个字母为小写
@Value 指定具体值,使Spring IoC给予对应属性注入对应值
@ComponentScan
定义需要扫描的路径并将标识需要装配( @Component、@Controller、@Service、@Repository)的类自动装配到Bean容器中
在没有定义路径的情况下,默认扫描当前包和其子包下的路径
可通过basePackageClasses定义扫描类
- includeFilters 定义满足过滤器(Filter)条件的Bean才去扫描
- excludeFilters 定义排除过滤器条件的Bean,都需要@Filter去定义
以下三种方式扫描到User类
@ComponentScan("com.springboot.chapter3.*")
@ComponentScan(basePackages = {"com.springboot.chapter3.pojo"})
@ComponentScan(basePackageClasses = {User.class})
excludeFilters Example:
@ComponentScan(basePackages = "com.springboot.chapter3.*", excludeFilters = {@Filter(classes = {Service.class})})
博主真是太厉害了!!!
叼茂SEO.bfbikes.com
怎么收藏这篇文章?
想想你的文章写的特别好https://www.ea55.com/
兄弟写的非常好 https://www.cscnn.com/
《北京遇上西雅图之不二情书》喜剧片高清在线免费观看:https://www.jgz518.com/xingkong/91495.html
《玛雅蜜蜂历险记2:蜜糖游戏》动画片高清在线免费观看:https://www.jgz518.com/xingkong/5055.html
你的文章让我学到了很多技能,非常实用。 http://www.55baobei.com/GdNreBL5uC.html
你的文章让我心情愉悦,真是太棒了! http://www.55baobei.com/zIhARQhDVQ.html
你的文章让我感受到了不一样的风景,谢谢分享。 http://www.55baobei.com/1XDpGM7kD5.html
《月吟》喜剧片高清在线免费观看:https://www.jgz518.com/xingkong/99606.html
你的文章让我感受到了不一样的风景,谢谢分享。 https://www.4006400989.com/qyvideo/87067.html
你的文章让我感受到了不一样的视角,非常精彩。 http://www.55baobei.com/lXRpQQhehV.html
你的才华横溢,让人敬佩。 https://www.4006400989.com/qyvideo/62859.html
《食人岛》恐怖片高清在线免费观看:https://www.jgz518.com/xingkong/55034.html
技术前瞻性分析体现行业敏感度。