File -> Project
下图配置是向当前工程中增加支持 Web 的能力
选择项目存放的位置
注:
如果在创建时 Spring Initializr 报错 Error:connect timed out,可参考:
https://celtics.blog.csdn.net/article/details/121063720
基础结构Spring Boot 的基础结构公三个文件:入口、配置文件、测试入口
MyspringbootApplication 为入口,是启动 Spring Boot 用到的。application.properties 为配置文件。MyspringbootApplicationTests 为测试入口
生成的 MyspringbootApplication 和 MyspringbootApplicationTests 类都是可以直接运行来启动当前创建项目的
pom.xml其中:
spring-boot-starter-web 向当前工程中增加支持 Web 的能力
spring-boot-maven-plugin 帮助在打包时,将所有的类和资源整合成一个独立的,可运行的 jar 包
如果我们想改变 Spring Boot 的版本
更改后,工程会对依赖进行重新的导入。如果没有,则右键 pom.xml 文件,右键 -> Maven -> Reimport
新建一个 Controller 类,Controller 对外提供接口
@RestController
public class ParaController {
@GetMapping({"/firstrequest"})
public String firstRequest(){
return "test1";
}
}
访问方式:http://127.0.0.1:8080/firstrequest



