官网教程 https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html
1.使用idea创建maven项目
2.在pom.xml中添加以下配置
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
</parent>
3.添加web依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
4.创建spring-boot入口程序类
App.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App
{
public static void main(String[] args)
{
SpringApplication.run(App.class,args);
}
}
5.编写控制器代码
MyController.java
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyController
{
@GetMapping("/")
public String hello()
{
return "Hello,World!";
}
}
6.启动spring-boot应用
mvn spring-boot:run
ok!应用启动成功,spring-boot就是这么简单!
原文:https://www.cnblogs.com/lypzzzzz/p/14956682.html