一:首先我们要建立一个新的springboot项目
选择下一步,
接着勾选需要的配置
点击下一步,这样就创建了一个springboot项目。
在application.properties中配置一下数据库连接,否则启动报错
spring.datasource.url=jdbc:mysql://localhost:3306/blue?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
现在运行启动类,结果如下,启动成功
二:编写controller测试
controller
@Controller
public class ShiroController {
@RequestMapping("test")
public String test(){
return "test";
}
}
html(在resources下templates中建立html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
成功访问!
</body>
</html>
测试,浏览器输入http://localhost:8080/test
出现以下,项目搭建成功