1、创建项目
选择spring Initalier, next
2、填写参数
点击next
3、选择web
4、加入依赖
在 pom.xml 中添加依赖
<!--前端模板thymeleaf启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--mybaits 启动器-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- 数据库 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--德鲁伊数据池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.9</version>
</dependency>
5、编辑配置文件 application.perproperties
spring.datasource.data-username=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=tiger
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
mybatis.type-aliases-package=com.weihuan.bean
mybatis.mapper-locations=classpath*:mapper/*.xml
5、创建目录结构,同时完成App 启动类的书写
6、创建helloworld control 控制类
@Controller
public class Hello {
@RequestMapping("/")
public String sayHello(){
return "hello";
}
}
7、创建hello.html
目录结构
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
hello!
</body>
</html>