springboot

Posted mryangjlpython

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot相关的知识,希望对你有一定的参考价值。

1.什么是springboot

  spring组件一站式解决方案,简化了各种配置,提供了启动器

2.为什么要用springboot

  a.独立运行,内置tomcat

  b.简化配置,自动配置,注解配置

  c.应用监控

3.核心配置文件

  application.yml和bootstrap.yml  bootstrap是应用程序的父上下文,优先级高于application,里面的属性不能被覆盖

  application主要用于项目的自动化配置,

  bootstrap用于,需要bootstrap连接配置中心,加载配置信息,一些不能覆盖的属性,一些加密解密的场景

4.yml文件不支持@PropertySource注解导入配置

5.核心注解@SpringBootApplication,

  @Configuration注解开启配置文件功能

  @EnableAutoConfiguration开启自动配置的功能

  @ComponentScan spring组件扫描

6.使用springboot项目两种方式

  a.继承spring-boot-starter-parent项目

  b.导入spring-boot-dependencies项目依赖

7.启动项目时运行特定代码,实现applicationRunner或者CommandLineRunner接口,后者可以获取命令行参数

8.一般的javabean都是单例,如果需要多例@Scope("prototype")

以上是关于springboot的主要内容,如果未能解决你的问题,请参考以下文章

SpringBootSpringBoot 自动配置原理

SpringbootSpringBoot基础知识及整合Thymeleaf模板引擎

SpringBootSpringBoot 缓存(十八)

SpringBootSpringBoot web开发

SpringBootSpringBoot Web开发

SpringBootSpringBoot 整合RabbitMQ(二十)