springboot创建项目时会自动在pom中生成依赖
<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>
<scope>runtime</scope>
</dependency>
在application.properties中配置mybatis扫描包
mybatis.mapper-locations=classpath:com/lgt/mapper/*.xml
配置mysql链接信息
spring.datasource.url=jdbc:mysql://192.168.5.128:3306/linksky_hr?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=myuser
spring.datasource.password=mypassword
我使用的是mysql6,所