pom中添加
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
1.在mian启动类上面添加注解@entityScan(“mapper包路径”)
2.在mapper上使用@service注解
3.在配置文件application.properties中添加
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc\:mysql\://localhost\:3306/Sopping?serverTimezone\=UTC&characterEncoding\=utf-8
spring.datasource.username = root
spring.datasource.password = root
因为不知道如何使用注解来扫描mapper.xml文件所以直接使用注解开发写sql语句了,有知道的大神还请告知