新建一个spring-boot项目,spring-boot是一个maven项目我们可以在eclipse上添加sts组件也可以在spring官网直接下载STS,完成之后重启新建一个spring-boot项目
选择依赖
finish
项目结构
我们在resources里面新建index.html,再java里面新建实体类包、控制器包,新建相应的类:Entity.class、userController.class
在spring-boot里面有个Application.java,这个东西相当于一个main方法,是整个项目的启动类,所有的代码都应该设置在该文件目录下以便扫描
配置thymeleaf模板引擎及mybatis,项目扫描路径等
spring.thymeleaf.prefix=classpath:/static/
spring.mvc.view.prefix=classpath:/static/
spring.thymeleaf.suffix=.html
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML5
pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>thymeleaf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>thymeleaf</name>
<description>Demo project for Spring Boot</descri