环境要求
SpringBoot:2.1.8.RLEASE(截止2019.9.28)
JDK:JDK1.8及以上
Spring:5.1.9.RELEASE及以上
支持编译工具如下:
| 编译工具 | 版本 |
|---|---|
| Maven | 3.3+ |
| Gradle | 4.4+ |
支持的内嵌Servlet容器:
| 名称 | Servlet版本 |
|---|---|
| Tomcat 9.0 | 4.0 |
| Jetty 9.4 | 3.1 |
| Undertow 2.0 | 4.0 |
创建项目
在线创建
使用网站start.spring.io/在线创建项目
删除导入项目自动生成的xxx.iml ,然后刷新下右侧maven tab即可
使用Maven创建
添加Pom文件
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
在src/java目录下创建包,并创建启动类FisrtApplication
package com.xyz;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class FirstApplication{
public static void main(String[] args) {
SpringApplication.run(FirstApplication.class, args);
}
@RequestMapping("/hello")
public String Hello() {
return "hello";
}
}
启动项目,访问:http://localhost:8080/hello,返回
使用IDEA工具创建
点击File-->New-->Project