1.脚手架搭建
https://start.aliyun.com/bootstrap.html
借助于阿里云脚手架,我们可以快速创建一个maven或gradle工程
如上图创建完之后,点击:浏览代码。即可查看代码大致目录结构,如下图
注意:这里默认的SpringBoot版本是3.0.2,其默认使用JDK需要17,一般建议大家使用低一点的版本,这里笔者采用的:2.7.6,即上图版本中的第二个。
2.代码导入
确认无误后,我们下载代码,并完成idea的工程导入
3.代码验证
1.引入web依赖
<!--引入springboot-web--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
2.编写访问入口
package com.yzxb.SpringSecurity.web; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("demo") public class HelloController { @GetMapping public String helloWorld() { return "Hello Spring Security"; } }
3.启动工程验证