- 环境准备
- controller层 html文件 jsp文件部分代码
写在前面:
本贴记录我在将ssm项目改为springboot+thymeleaf过程中遇到的问题,数据访问层使用mapper(接口),使用@Insert、@Update、@Delete、@Select注解操作数据库,仅学习记录非教程。
作业要求:新建一个Spring Boot的项目,将作业2(SSM框架实现)中的实体类、数据访问层和Controller的代码复制到本项目中,然后将作业2中的JSP页面改成用Thymeleaf来实现。
1.1.idea新建springboot项目,添加依赖包
maven添加依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
version>2.2.2</version>
</dependency>
1.2 编写配置文件application.properties
spring.thymeleaf.cache=false
spring.thymeleaf.encoding=utf-8
spring-thymeleaf.mode=HTML
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.messages.basename=i18n.login
#文件上传配置
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=50MB
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/javawebwork?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.show-sql=true
spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.password=root
spring.cache.redis.time-to-live=60000
#整合mybatis
#给pojo实体类起别名
mybatis.type-aliases-package