Spring Boot之hello world!
一、创建maven工程
二、引入依赖
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.3</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
三、创建主程序
/** * 主程序类 * @SpringBootApplication:这是一个SpringBoot应用 */ @SpringBootApplication public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class,args); } }
四、编写业务
@RestController public class HelloController { @RequestMapping("/hello") public String handle01(){ return "Hello, Spring Boot 2!"; } }
五、测试
运行main方法
六、效果展示