SpringBoot学习笔记

一、相关知识了解

  1、spring官网 https://spring.io

  2、springboot核心思想:约定大于配置

  3、springboot最大的两个优势:简化配置 和 依赖管理

  4、springboot的web工程启动:Java -jar

  5、单词了解:微服务架构 Microservice Architecture  智能 intelligence 组件 component  库 libraries banner 横幅 retention 保留  enable 激活;启用

  6、官网版本:snapshot 快照版 不稳定   Current 最新版 不一定稳定    GA 稳定版

二、自动配置原理

1)、pom.xml

  1、springboot的groupId一般为:org.springframework.boot      springboot的artifactId一般为:spring-boot-starter-***

  2、springboot项目中的pom.xml中有一个父项目,父项目中有dependencyManagement和plugManagement ,声明了大量的依赖和插件。因此在springboot项目中,引入启动器和插件可以不指定版本

2)、@SpringBootApplication 启动引导类注解

  @Target 标注注解的使用范围

  @Retention 保留时机

  @RestController=@Responsebody+@Controller 

  @interface 注解类 自动继承注解接口

  @SpringBootConfiguration   @configuration 声明类为配置类,此类内部有一个或多个@Bean  @Component

  @ComponentScan 扫描同级目录下的类(所以建包时,要建在启动类的同级目录)

  @EnableAutoConfiguration      

    加载spring.factories这个文件,这个文件中有大量的以autoConfiguration结尾的配置类,通过pom.xml确定这些配置类是否会生效。这些配置类会加载以properties结尾的配置类。这些配置内有默认属性并与yml文件绑定。我们可以通过yml中的设置修改默认的设置。

三、相关技术集成

  1、导入静态资源:访问/**  默认映射访问/resources /static(习惯) /public
  2、首页和图标定制:默认访问静态资源路径下的index.html,templates目录下的所有页面只能通过controlle来跳转,图标定制:favicon.ico 放在static目录下

  3、Thymeleaf 使用:导入启动器,html放入templates就可以了。html 引入xmlns:th="http://www.thymeleaf.org",并且th: 可接替HTML所有标签

--------------------------------------------------------------------------------------------------------------

未完待续。。。

原文地址:https://www.cnblogs.com/LiuChengGang/p/14059512.html