【java】— 第一个Spring Boot应用程序
1.Spring Boot环境部署:https://blog.youkuaiyun.com/L19002S/article/details/106909810
2.搭建项目所需环境:
1.IntelliJ IDEA 2019.1.3 x64
2.apache-maven-3.6.3
3.JDK1.8或JDK1.8以上,否则Spring Boot运行报错(这里是最坑爹的地方,一定要注意,笔者在这卡了一天,因为我用的时JDK1.7)
3.环境准备!
点击File—>New—>Project弹出以下界面

点击Next弹出以下界面

点击Next弹出以下界面

这里给项目命名

4.项目总体结构图

5.主程序代码
HelloApplication.java
package com.example.helloo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HellooApplication {
public static void main(String[] args) {
SpringApplication.run(HellooApplication.class, args);
}
}
application.yml
server:
port: 8080
HelloController类
package com.example.helloo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping(value = "/hi")
public String sayHello(){
return "Hello Springboot ";
}
}
6.使用浏览器向服务器发送请求
URL:http://localhost:8080/hi
7.Web界面展示

本文详细介绍如何从零开始搭建SpringBoot项目,包括环境配置、项目结构、主程序代码及控制器实现,最后通过浏览器验证项目运行。

被折叠的 条评论
为什么被折叠?



