spring boot +thymeleaf+ mybatis
Posted 清茶与酒,白茶与风。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot +thymeleaf+ mybatis相关的知识,希望对你有一定的参考价值。
pom
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.wzq.ssm</groupId> <artifactId>springboot-yueqian-demo2</artifactId> <version>0.0.1-SNAPSHOT</version> <name>springboot-yueqian-demo2</name> <description>Demo project for Spring Boot</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.10</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <!--pagehelper --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.3</version> <exclusions> <exclusion> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
yml
spring: datasource: driver-class-name: com.mysql.jdbc.Driver username: root password: root url: ‘jdbc:mysql://localhost:3306/springbootdb?useUnicode=true&characterEncoding=UTF-8‘ pagehelper: helper-dialect: mysql reasonable: true
主函数
package com.wzq.ssm; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan("com.wzq.ssm.dao") public class SpringbootYueqianDemo2Application { public static void main(String[] args) { SpringApplication.run(SpringbootYueqianDemo2Application.class, args); } }
以上是关于spring boot +thymeleaf+ mybatis的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例
spring boot(十五)spring boot+thymeleaf+jpa增删改查示例