1、导入SpringBoot相关依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
2、编写主启动类
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class,args);
}
}
3、编写controller
@RestController
public class HelloWordController {
@GetMapping("/hello")
public String hello() {
return "hello word SpringBoot2";
}
}
4、输入地址测试,正常访问
http://127.0.0.1:8080/hello