日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

使用Spring Initializer快速创建Spring Boot项目

發布時間:2025/4/16 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用Spring Initializer快速创建Spring Boot项目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用Spring Initializer快速創建Spring Boot項目

1、IDEA:使用 Spring Initializer快速創建項目

IDE都支持使用Spring的項目創建向導快速創建一個Spring Boot項目;

選擇我們需要的模塊;向導會聯網創建Spring Boot項目;

默認生成的Spring Boot項目;

  • 主程序已經生成好了,我們只需要我們自己的邏輯

  • resources文件夾中目錄結構

    • static:保存所有的靜態資源; js css images;

    • templates:保存所有的模板頁面;Spring Boot默認jar包使用嵌入式的Tomcat,默認不支持JSP頁面);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?可以使用模板引擎(freemarker、thymeleaf)

? ? ? ? ? ? ? application.properties:Spring Boot應用的配置文件;可以修改一些默認設置;


SpringBoot01HelloworldQuickApplication.java

package com.dym.springboot;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication public class SpringBoot01HelloworldQuickApplication {public static void main(String[] args) {SpringApplication.run(SpringBoot01HelloworldQuickApplication.class, args);}}

HelloController.java

package com.dym.springboot.controller;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController;//這個類的所有方法返回的數據直接寫給瀏覽器,(如果是對象轉為json數據) /*@ResponseBody @Controller*/ @RestController public class HelloController {@RequestMapping("/hello")public String hello(){return "hello world quick!";} }


總結

以上是生活随笔為你收集整理的使用Spring Initializer快速创建Spring Boot项目的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。