intellij idea2021.2:創建一個springboot項目(springboot 2.5.4)


一,點擊 New Project 按鈕

說明:劉宏締的架構森林是一個專注架構的博客,地址:https://www.cnblogs.com/architectforest

         對應的源碼可以訪問這里獲取: https://github.com/liuhongdi/

說明:作者:劉宏締 郵箱: 371125307@qq.com

二,配置項目的信息

      從左側菜單選擇: Spring Initializr,
       並進行配置,如圖:
    點 Next 按鈕

三,依賴頁面:

       選中 Spring Web一項
點Finish 按鈕創建項目

四,項目創建成功,如圖:

五,添加一個controller

src/main/java/com.lhd.hellospring目錄->右鍵->New->Package
輸入包名controller后回車
在controller目錄上右擊,New->Java Class,如圖:
輸入class 名稱 HomeController后回車
修改 HomeController的內容如下:
package com.lhd.hellospring.controller;
 
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/home")
public class HomeController {
    
    @GetMapping("/home")
    public String home() {
        return  "this is home page!";
    }
}

六,測試這個web項目:

1,執行后端程序:
選中HellospringApplication,右鍵->Run ‘HellospringApplication'
 
2,從瀏覽器訪問:
http://127.0.0.1:8080/home/home 
效果如圖:

七,查看intellij idea的版本:

Help->About
如圖:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM