以下两种任选其一即可,默认优先级properties>yml>yaml(优先级在源码中可以查看)
.yml文件的配置
# datasource
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/testedu?useSSL=false&serverTimezone=UTC
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
# mybatis
mybatis:
mapper-locations: classpath:mapper/*Mapper.xml #mapper映射文件路径
type-aliases-package: com.zeke.pojo
# config-location: #指定mybatis的核心配置文件
.properties文件的配置
#DB Configuration:
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/testedu?useSSL=false&useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=123456
#spring集成Mybatis环境
#pojo别名扫描包
mybatis.type-aliases-package=com.zeke.pojo
#加载Mybatis映射文件
mybatis.mapper-locations=classpath:mapper/*Mapper.xml