连接数据库
spring:
datasource:
username: root
password: 123
url: jdbc:mysql://localhost:3306/twl?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
driver-class-name: com.mysql.cj.jdbc.Driver
#整合mybatis
mybatis:
mapper-locations: classpath:mapper/*.xml
mybatis+mysql依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
xml头
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tao.crud.mapper.UserMapper">
<select id="queryUser" resultType="com.tao.crud.pojo.User">
select * from twl.users where userName=#{userName} and password=#{userPassword}
</select>
</mapper>