SpringBoot项目的构建
搭建的流程
- 使用idea快速构建一个springboot工程
- 认识springboot的目录结构
- 运行springboot项目
准备工作
- jdk1.8+
- maven3.5+
Spring Boot 2.4.6 requires Java 8 and is compatible up to Java 16 (included). Spring Framework 5.3.7 or above is also required.
如果你使用springboot2.4.6版本必须是jdk1.8。
并且spring的版本的依赖是:spring5.3.7版本。maven版本是:3.5+ 。
内置Romcat的版本:9x
创建的过程
1、打开idea
2、选择依赖starter
3、创建完成
4、创建成功
5、测试工程是否成功有效
新建一个IndexController.java, 如下:
package com.example.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@GetMapping("/index")
public String test(){
return "sucess";
}
}
启动的主类 DemoApplication.java
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
访问http://localhost:8080/index
搭建完毕