1.新建maven项目
2.配置pom.xml中的parent为spring-boot-starter-parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
3.配置pom.xml中dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
4.编写启动类
@SpringBootApplication
public class MainAppliction {
public static void main(String[] args) {
SpringApplication.run(MainAppliction.class, args);
}
}
注:
1)@SpringBootApplication : 是Sprnig Boot项目的核心注解,目的是开启自动配置
2)启动类建议放到项目的根目录下面
5.编写controller
@RestController
public class HelloWorldController {
@RequestMapping("/hello")
private String home() {
return "hello world";
}
}
6.使用http://127.0.0.1:8080/hello访问
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。