一、maven构建springboot
1、需求:
搭建SpringBoot工程,定义HelloController.hello()方法,返回”Hello SpringBoot!”。
2、实现步骤:
- 创建Maven项目 springboot-helloworld 
- 导入SpringBoot起步依赖 
<!--springboot工程需要继承的父工程-->
    <parent>
      <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
    </parent>
    <dependencies>
        <!--web开发的起步依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>- 定义Controller编写引导类 - @SpringBootApplication//表示这个类 是springboot主启动类。 public class HelloApplication { public static void main(String[] args) { SpringApplication.run(HelloApplication.class,args); } }
- 定义Controller - @RestController @RequestMapping("/hello") public class HelloController { @GetMapping("/test") public String test1(){ return "Hello SpringBoot!"; } }
- 启动测试 访问: http://localhost:8080/hello/test 
3、总结
- 启动springboot一个web工程 
- pom 规定父工程,导入web的起步依赖 
- 主启动类 @SpringBootApplication、main 
- 业务逻辑 controller,service,dao - SpringBoot在创建项目时,使用jar的打包方式。 java -jar xxx.jar 
- SpringBoot的引导类,是项目入口,运行main方法就可以启动项目。 
- 使用SpringBoot和Spring构建的项目,业务代码编写方式完全一样。 
 
二、快速构建springboot




三、SpringBoot起步依赖原理分析-理解
- 在spring-boot-starter-parent中定义了各种技术的版本信息,组合了一套最优搭配的技术版本。
- 在各种starter中,定义了完成该功能需要的坐标合集,其中大部分版本信息来自于父工程。
- 我们的工程继承parent,引入starter后,通过依赖传递,就可以简单方便获得需要的jar包,并且不会存在版本冲突等问题。

 
  
  
 