idea2021创建springboot项目
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路由