SpringBoot的application.properties配置学习

1. 开发/测试/生产环境配置

spring.profiles.active=xxxx

该系统变量可以指明要使用的配置文件,一般应用于多环境配置分离,如生产环境(production),开发环境(development),测试环境(test)等,可以自定义,如开发环境配置文件为application-dev.properties,则spring.profiles.active=dev,在启动时会加载application-dev.properties配置文件。

2. MySQL数据源配置

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xx?useUnicode=true&characterEncoding=utf-8&useSSL=false

spring.datasource.driver-class-name= com.mysql.jdbc.Driver

spring.datasource.username=root

spring.datasource.password=root

3. Redis配置

spring.redis.host=localhost

spring.redis.port=6379

4. Mybatis配置(引入mybatis-spring-boot-starter自动集成)

mybatis.type-aliases-package=com.xx.cdn.entity

mybatis.mapper-locations=classpath:mybatis/mapper/**/*.xml

mapper.mappers=com.xx.common.core.mapper.CustomMapper

5. 文件上传配置

spring.servlet.multipart.max-request-size= 50MB

spring.servlet.multipart.max-file-size= 10MB

6. logging

logging.path=./logs

logging.level.default=INFO

logging.level.root=${logging.level.default}

logging.config=classpath:log4j2.xml

原文地址:https://www.cnblogs.com/LittleMike/p/11888923.html