Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".
We take an opinionated view of the Spring platform(平台) and third-party libraries so you can get started with minimum fuss(无谓的忧虑). Most Spring Boot applications need minimal Spring configuration.
Features
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Provide opinionated 'starter' dependencies to simplify your build configuration
Automatically configure Spring and 3rd party libraries whenever possible
Provide production-ready features such as metrics, health checks, and externalized configuration
Absolutely no code generation and no requirement for XML configuration
官方地址:https://spring.io/projects/spring-boot
第一课学习笔记
1.简化Spring应用开发,整合Spring技术栈
2.使用嵌入式Servlet容器,不用打包成war
3.无需配置xml
4.微服务概念,是一种架构风格
5.环境配置,需要设置maven、IDEA
6.注释:
@SpringBootApplications 主程序注释
@Controller
@SpringBootMapping("/helloWorld") 识别浏览器的请求
@SpringBootConfiguration 配置类
@AutoCofigurationPackage 自动配置包
7.轻松创建可执行jar包
8.pom文件管理以来
9.官网有场景pom文件导入
补充
The
@RestController
annotation tells Spring that this code describes an endpoint that should be made available over the web. The@GetMapping(“/hello”)
tells Spring to use ourhello()
method to answer requests that get sent to thehttp://localhost:8080/hello
address. Finally, the@RequestParam
is telling Spring to expect aname
value in the request, but if it’s not there, it will use the word “World” by default.
@RestController
注解告诉Spring这个代码描述了一个可以适用于web的尾端。@GetMapping(“/hello”)
告诉Spring,当发送请求到http://localhost:8080/hello
,使用我们的hello()
方法来回答这个问题。最后,@RequestParam
告诉Spring,请求一个name
值,但是如果不存在,默认情况下它将使用单词“ World”。
@SpringBootApplication:申明让spring boot自动给程序进行必要的配置。
@Controller:用于定义控制器类,在spring项目中由控制器负责将用户发来的URL请求转发到对应的服务接口,通常需要配合注解@RequestMapping。
@RequestMapping:提供路由信息,负责URL到Controller中的具体函数的映射。
@EnableAutoConfiguration:SpringBoot自动配置,尝试根据你添加的jar依赖自动配置你的Spring应用。
@Configuration:相当于传统的xml配置文件,如果有些第三方库需要用到xml文件,建议仍然通过@Configuration类作为项目的配置主类,可以使用@ImportResource注解加载xml配置文件。
@Import:用来导入其他配置类。
@ImportResource:用来加载xml配置文件。
@Autowired:自动导入依赖的bean。
@Bean:等价于XML中配置的bean。