标签:mybatis mapping map jdbc medium tap 图片 tar time
1.在pom.xml中引入springBoot与mybatis的整合的jar包,注意别引错:
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.3</version> </dependency>
2.在springBoot的配置文件:application.yml配置mybatis相关的属性:
spring:
#配置数据源
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/demo1?serverTimezone=UTC
username: root
password: root
#配置mybatis相关属性
mybatis:
#配置mybatis的mapper.xml文件的位置
mapper-locations: classpath:mapping/*Mapper.xml
#配置实体类的包别名
type-aliases-package: com.yzy.springbootdemo.entity
3.在resources目录下创建mapping文件夹存放mapper.xml(与上面配置文件中配置的mapper-locations对应)
4.在启动类中添加注解@MapperScan("对应的dao接口的路径")
@SpringBootApplication @MapperScan("com.yzy.springbootdemo.dao") public class SpringbootdemoApplication { public static void main(String[] args) { SpringApplication.run(SpringbootdemoApplication.class, args); } }
标签:mybatis mapping map jdbc medium tap 图片 tar time
原文地址:https://www.cnblogs.com/shouyaya/p/13081608.html