0
点赞
收藏
分享

微信扫一扫

idea2021创建springboot项目

唯米天空 2022-04-13 阅读 63

idea2021创建springboot项目

文章目录

记录一下创建过程

创建项目

File–>new–>Project
选择Spring Initializr
在这里插入图片描述

选择spring web
在这里插入图片描述

默认目录下,会有个DemoApplication.java
在这里插入图片描述

此时可以直接run,我当时需要download一些东西(我看其他大佬的博客上需要修改pom.xml,但是我没有)

不用配tomcat,Spring自带了tomcat
默认情况下会在本地的8080端口上访问到127.0.0.1:8080

在这里插入图片描述

修改端口

如果需要修改端口的,可以在resources中进行修改
在这里插入图片描述

新建一个类测试

然后新建一个HelloController进行测试

package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello world";
    }
}

运行,访问/hello路由

在这里插入图片描述

参考文章

  1. 如何创建一个springboot项目
举报

相关推荐

0 条评论