intellij idea2021.2:创建一个springboot项目(springboot 2.5.4)
一,点击 New Project 按钮
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126059-314498808.png)
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/27/intellij-idea2021-2-chuang-jian-yi-ge-springboot-xiang-mu/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,配置项目的信息
从左侧菜单选择: Spring Initializr,
并进行配置,如图:
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126295-119094570.png)
点 Next 按钮
三,依赖页面:
选中 Spring Web一项
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126340-2138075369.png)
点Finish 按钮创建项目
四,项目创建成功,如图:
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126358-85983203.png)
五,添加一个controller
src/main/java/com.lhd.hellospring目录->右键->New->Package
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126317-359424191.png)
输入包名controller后回车
在controller目录上右击,New->Java Class,如图:
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126242-1831791056.png)
输入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'
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126520-1690401973.png)
2,从浏览器访问:
http://127.0.0.1:8080/home/home
效果如图:
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103126046-1322971578.png)
七,查看intellij idea的版本:
Help->About
如图:
![](https://img2020.cnblogs.com/blog/1938691/202108/1938691-20210823103125877-1726459550.png)