0%

SpringBoot快速入门

环境搭建

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!-- 所有的springboot工程都必须继承spring-boot-starter-parent -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
</parent>

<dependencies>
<!-- web功能 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

Application.java

1
2
3
4
5
6
7
8
9
10
11
12
package com.swifter;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

Controller

1
2
3
4
5
6
7
8
9
10
11
12
13
package com.swifter.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@RequestMapping("quick")
public String quick() {
return "Hello world!";
}
}

SpringBoot热部署

1
2
3
4
5
<!-- 热部署 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

image-20191206204647986

cmd+shift+a -> Registry…

image-20191206204647986

–EOF–