Java SpringBoot 创建项目工程输出 Hello World
-  1、新建项目 
  
-  2、创建 controller 
  
-  3、编写 Hello World 代码 
package com.zhong.demo01.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @ClassName : HelloController* @Description : 向浏览器输出 Hello World* @Author : zhx* @Date: 2024-02-26 15:45*/@RestController
public class HelloController {@RequestMapping("/hello")public String hello() {return "Hello World !";}
}
- 4、运行 SpringBootApplication
  
- 5、控制台输出
  
- 6、浏览器访问
http://localhost:8080/hello

- 7、如果端口冲突。
修改 application.properties
server.port=9090
server.servlet.context-path=/app

重新启动

http://localhost:9090/app/hello
成功访问

- 注意
 