1 springboot 項目創建的3種方法
1.1 在線創建
https://start.spring.io/
1.2 通過IDE創建
1.2.1 IDEA創建 springboot項目
1.2.2 STS 創建 springboot項目
1.3 改造普通 maven 工程
- 添加依賴
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.15.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
- 添加啓動類
package com.tzb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class App {
@RequestMapping("/")
public String hello(){
return "hello world";
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}