vscode搭建spring boot项目
一.创建项目
第一步:打开vscode按下shift+ctrl+p,选择下面的
第二步:选择版本
第三步:选择语言
第四步:填写项目的Groupid
第五步:填写Artifact id
第六步:选择打包方式
第七步:选择java版本
第八步:选择依赖工具
二.创建项目目录如下:
二.建立HelloController.java内容如下:
package example.example1;import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@CrossOrigin // 允许所有跨域请求(仅用于开发)
public class HelloController {@GetMapping("/hello")public String hello() {return "你好,Spring Boot! 当前时间: " + new java.util.Date();}
}
三.点击主程序(Example1Application.java)点击运行
四.打开浏览器,输入:http://localhost:8080/hello
这样一个简单的spring boot项目就成功部署啦!