本网站(662p.com)打包出售,且带程序代码数据,662p.com域名,程序内核采用TP框架开发,需要联系扣扣:2360248666 /wx:lianweikj
精品域名一口价出售:1y1m.com(350元) ,6b7b.com(400元) , 5k5j.com(380元) , yayj.com(1800元), jiongzhun.com(1000元) , niuzen.com(2800元) , zennei.com(5000元)
需要联系扣扣:2360248666 /wx:lianweikj
SpringBoot微服务框架
一路向西 · 373浏览 · 发布于2020-11-18 +关注

springboot

  • 是什么?

  • 配置如何编写 yaml

  • 自动装配原理

  • 集成Web开发

  • 集成数据库Druid

  • 分布式开发:Dubbo(RPC)+zookeeper

  • swagger:接口文档

  • 任务调度

  • SpringSecurity : Shiro

自动装填原理
pom.xml
核心依赖在父工程中:<artifactId>spring-boot-dependencies</artifactId>
我们在写或者引入一下SpringBoot依赖的时候,不需要指定版本,就因为有这些版本仓库

启动器
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
Springboot的启动环境
例如:spring-boot-starter-web,它就会帮我们自动导入web环境的所有依赖
Springboot会将所有的功能,都变成一个个的启动器
如果要是有什么功能,只需找到对应的启动器即可

spring-boot-starter:核心模块,包括自动配置支持、日志和YAML;
spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito;
@RestController的意思就是controller里面的方法都以json格式输出;

主程序
//@SpringBootApplication : 标注这个类是SpringBoot的应用
@SpringBootApplication
public class Springboot01Application {
    public static void main(String[] args) {
        // 将SpringBoot应用启动
        SpringApplication.run(Springboot01Application.class, args);
    }
}
注解@SpringBootConfiguration:SpringBoot的配置    
@Configuration:spring配置类    
@Component:spring组件@EnableAutoConfiguration:自动配置    
@AutoConfigurationPackage:自动配置包        
@Import(AutoConfigurationPackages.Registrar.class):自动配置'包注册'
    @Import(AutoConfigurationImportSelector.class):自动配置选择器
获取所有的配置List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes);
配置候选的配置
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {   
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(),
         getBeanClassLoader());
   Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you "
         + "are using a custom packaging, make sure that file is correct.");   return configurations;
}

META-INF/spring.factories自动配置的核心文件

结论:springboot所有的自动配置都是在启动的时候扫描并加载spring.factories所有的自动配置类都在这个里面,但是不一定生效要判断条件是否成立,只要导入了对应的start就有对应的启动器,有了启动器,自动装配就会生效,然后配置成功
步骤:
1.springboot在启动的时候,从类路径下/META-INF/spring.factories获取指定的值
2.将这些自动导入配置的类导入容器,自动配置就会生效,帮我进行自动配置
3.一起我们需要自动配置的东西,现在springboot帮我们做了
4.整合JavaEE,解决方案和自动配置的东西都在spring-boot-autoconfigure-2.3.5.RELEASE.jar这个包下面
5.它会把所有需要导入的组件,以类名的方式返回,这些组件就会添加到容器;
6.容器中也会存在非常多的xxxAutoConfiguration的文件(@Bean),就是这些类给容器中导入了这个场景需要的所有组件


相关推荐

PHP实现部分字符隐藏

沙雕mars · 1322浏览 · 2019-04-28 09:47:56
Java中ArrayList和LinkedList区别

kenrry1992 · 906浏览 · 2019-05-08 21:14:54
Tomcat 下载及安装配置

manongba · 966浏览 · 2019-05-13 21:03:56
JAVA变量介绍

manongba · 960浏览 · 2019-05-13 21:05:52
什么是SpringBoot

iamitnan · 1084浏览 · 2019-05-14 22:20:36
加载中

0评论

评论
欢迎大家关注我,有技术问题可以一起交流探讨!
分类专栏
小鸟云服务器
扫码进入手机网页