SpringBoot 针对不同的开发场景提供默认的属性配置,如果默认的配置不能满足开发的需要,我们需要对属性配置进行整改
SpringBoot应用提供了一个全局配置文件------application.properties 用于进行自定义配置
全局配置文件支持2中语法配置:
- properties 键值对配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql:///springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=111111
mybatis.mapper-locations=classpath:mappers/*Mapper.xml
mybatis.type-aliases-package=com.qfedu.springboot.demo1.entity
- yaml语法的配置
spring:
datasource:
url: jdbc:mysql:///springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 111111
mybatis:
mapper-locations: classpath:mappers/*Mapper.xml
type-aliases-package: com.qfedu.springboot.demo1.entity
常用的全局配置
server:
port: 9999
servlet:
context-path: /demo1