1.引入依赖(一个是mybatis的依赖用来操作数据库,另一个是postgresql如果需要mysql引入mysql的)
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
2.配置application.yml配置文件
spring:
datasource:
name: postgresql
driver-class-name: org.postgresql.Driver
url: 'jdbc:postgresql://localhost:5432/test'
username: postgres
password: 123456
spring与mybatis都是根节点 ,然后也在application.yml文件中配置mapper文件(映射文件)的sql可以被扫描到,
mybatis:
mapper-locations: classpath:mapper/*.xml