使用 IDEA 直接創建項目
1、創建一個新項目
2、選擇spring initalizr
選擇初始化組件Web
等待項目構建成功
在com.longdi.helloworld包下新建一個HelloController類
package com.longdi.helloworld.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @author: 弟 * @description * @date: 2021/9/29 13:03 */ @RestController public class HelloController { //接口:http://localhost:8080/hello @RequestMapping("hello") public String hello(){ //調用業務,接收前端的參數 return "hello world"; } }
項目結構
啟動項目,即可在瀏覽器顯示HelloWorld!
http://localhost:8080/hello
只需要幾步,就可以完成一個web接口的開發,SpringBoot就是這么簡單
將項目打成jar包,點擊 maven的 package
如果打包成功,則會在target目錄下生成一個 jar 包
打成了jar包后,就可以在任何地方運行了!
如何更改啟動時顯示的字符拼成的字母,也就是 banner 圖案
只需一步:到項目下的 resources 目錄下新建一個banner.txt 即可。
SpringBoot操作起來如此簡單,我們之后去進行一波源碼研究分析!
歡迎來我的Github:https://github.com/dragon-idea
到此這篇關于一分鐘入門Java Spring Boot徹底解決SSM配置問題的文章就介紹到這了,更多相關Java Spring Boot SSM 配置內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://blog.csdn.net/weixin_48838340/article/details/120549896