Spring Boot核心原理2

1.自定义注解:用官方元注解(标注注解的注解),@interface声明

@Target(ElementType.TYPE)                         作用在TYPE上

@Retention(RetentionPolicy.RUNTIME)         生效时机
@Documented                                                生成文档
@Inherited                                                      使注解具有继承性

2.字段:通过方法声明的方式如 String value() default '';

1. 获取解析注解类AnnotationAttributes

2.类上有注解?有获取打印

3.批量导入配置类import(xxx.class)

3.xml文件与注解

   解析xml文件:bean->反射创建对象->map.put("",)ioc容器有了@Autowired

配置文件bean.xml自动装配bean:@springbootconfiguration同@configuration->@component{@controller、@service、@repository}

@ComponentScan(“”)同<component-scan base-package=“”>将扫描包下的类交给spring ioc容器:局限性到达包里的bean,若bean不在业务内,未来要用,可通过配置文件import(xxx.class),xxx.class实现了importSelector接口,重写selectimports方法,自动装配去找META-INF下的spring.factories文件

@EnableAutoConfiguration自动装配第三方jar也是这样批量导入的,具体可ctrl + shift + alt + u 查看类图

@Conditional(xxx.class)条件装配。xxx.class实现condition接口

组件:create、prepare准备、refresh是核心、afterRefresh

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值