intellij idea2021.2:创建一个springboot项目(springboot 2.5.4)

一,点击 New Project 按钮

说明:刘宏缔的架构森林是一个专注架构的博客,

网站: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,
       并进行配置,如图:
    点 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
如图:
posted @ 2021-08-23 10:31  刘宏缔的架构森林  阅读(3358)  评论(0编辑  收藏  举报