【java】— 第一個Spring Boot應用程序
1.Spring Boot環境部署:https://blog.csdn.net/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界面展示