框架学习随笔2-SpringBoot简介

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 our hello() method to answer requests that get sent to the http://localhost:8080/hello address. Finally, the @RequestParam is telling Spring to expect a name 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。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值