zoukankan      html  css  js  c++  java
  • 后端——框架——容器框架——spring_boot——《官网》阅读笔记——第二章节

      第二章节介绍spring boot,从三个层面

    1. What:概念,spring boot是什么?
    2. How: 系统配置,安装spring boot, 编写Hello World示例项目
    3. Why:spring boot的优点?

    1、概念

      引用原著中的定义:

      Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run

      我理解这句话的关键点有两个:第一个是spring boot应用场景是spring-based application。第二个是spring boot的职责,它使得这些项目更容易创建。

      所以学习spring-core是spring-boot的基础。

    2、使用

      介绍How的部分有三个小节。

    1. 第二小节介绍spring boot需要的最低配置,例如JDK最低版本,Servlet最低版本,maven最低版本等等。本文略。
    2. 第三小节介绍安装spring boot,介绍了很多方式
    • Maven:添加spring-boot-starter-xx的依赖
    • Gradle:略。
    • CLI:下载spring cli,添加install/bin到系统环境变量下,运行spring init命令,在第七章节介绍。
    • Sdkman:省略。
    • Homebrew:Mac操作系统。Homebrew安装工具, MacPorts安装工具
    • Scoop:Window操作平台,scoop安装工具。

      3.第四小节介绍编写Hello World项目的实例。

    2.1  Hello World示例

      编写spring boot项目的步骤如下

    1. 验证环境,maven,JDK等已安装好。
    2. 在maven项目中添加spring-boot-starter-xx依赖,web项目必须添加spring-boot-starter-web依赖。
    3. 编写HelloController,方法Hello,返回Hello World字符串。
    4. 编写启动类HelloApp,添加main方法,在类上添加@Configuration,@EnableAutoConfiguration注解,@ComponentScan注解。
    • @Configuration代表配置类,是spring-core注解方式获取配置信息的核心注解
    • @EnableAutoConfiguration:自动注入,是spring boot的核心功能。
    • @ComponentScan:扫描依赖的包路径。

    5.如果需要将项目打包成jar,运行mvn package命令。

    3、优点

      引用原著中的内容:

      Provide a radically faster and widely accessible getting-started experience for all Spring development

      构建性能更好,更容易创建的app

      Be opinionated out of the box but get out of the way quickly as requirements start to diverge from the defaults

      自动注入

      Provide a range of non-functional features that are common to large classes of projects (such as embedded servers, security, metrics, health checks, and externalized configuration)

      集成了很多功能,例如内嵌Web容器,安全框架,指标监控,健康状态,也可以自己扩展。

      Absolutely no code generation and no requirement for XML configuration

      不在使用XML配置方式,而是纯注解方式。no code generation

  • 相关阅读:
    删除ubuntu多余内核
    Linux从入门到精通(第8章--磁盘管理)
    图书销售管理系统概要设计,系统数据结构设计分工
    图书管理销售系统,出错设计部分
    图书管理销售系统概要分析,接口设计部分
    图书管理销售系统,运行设计部分
    图书管理销售管理系统,总体设计部分
    图书销售管理概要分析报告,引言部分
    图书销售管理系统概要分析报告总体分工
    图书销售管理系统需求分析,各种功能图部分
  • 原文地址:https://www.cnblogs.com/rain144576/p/12498507.html
Copyright © 2011-2022 走看看