创建SpringBoot项目,启动后,默认的访问路径即主机IP+默认端口号8080:http://localhost:8080/
此时,我们就可以访问Controller层的接口了,如:http://localhost:8080/hello
package com.springboot.test; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class SpringBootTest { @RequestMapping("/hello") public String helloSpringBoot() { return "Hello SpringBoot Project."; } }
当然,我们可以通过配置来更改默认端口和项目访问路径:
修改端口号