SpringBoot配置文件示例
一、application.properties
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# .::::. .::::. #
# .::::::::. .::::::::. #
# ::::::::::: ::::::::::: #
# ..:::::::::::' ':::::::::::.. #
# '::::::::::::' '::::::::::::' #
# .:::::::::: ::::::::::. #
# '::::::::::::::.. ..::::::::::::::` #
# ..::::::::::::. .::::::::::::.. #
# ``:::::::::::::::: ::::::::::::::::`` #
# ::::``:::::::::' .:::. .:::. ':::::::::'':::: #
# ::::' ':::::' .::::::::. .::::::::. ':::::' ':::: #
# .::::' :::: .:::::::'::::. .::::':::::::. :::: '::::. #
# .:::' ::::: .:::::::::' ':::::. .:::::' ':::::::::. ::::: ':::. #
# .::' :::::.:::::::::' ':::::. .:::::' ':::::::::.::::: '::. #
# .::' ::::::::::::::' ``::::. .::::`` `:::::::::::::: '::. #
# ...::: ::::::::::::' ``::. .::`` `:::::::::::: :::... #
# ````':. ':::::::::' ::::.. ..:::: `:::::::::' .:' ````#
# '.:::::' ':'````.. ..```':' `:::::.' #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ========================== 应用名称 ==========================
spring.application.name=Sb-MulDemo
server.port=8508
# ========================== 编码设置 ==========================
server.servlet.encoding.force=true
server.servlet.encoding.charset=UTF-8
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=1000MB
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
# ======================= 数据库基础配置 =======================
spring.datasource.name=druidDataSource
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# ========================== 日志配置 ==========================
# logging.config: classpath:logback-spring.xml
# logging.path: C:\Users\公用\Desktop\logs
# logging.level.com.modules.service=debug
# ======================= Redis基础配置 ========================
spring.redis.database=0
spring.redis.timeout=9000
spring.redis.port=6379
# ====================== Rabbitmq基础配置 ======================
spring.rabbitmq.connection-timeout=9000
spring.rabbitmq.port=5672
# ======================== Mybatis-Plus ========================
mybatis-plus.mapper-locations=classpath:mapper/*/*Mapper.xml
mybatis-plus.type-aliases-package=com.fhiguin.model
# 显示Sql
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# 使用jdbc的getGeneratedKeys获取数据库自增主键值
mybatis-plus.configuration.use-generated-keys=true
# 使用列标签替换列别名
mybatis-plus.configuration.use-column-label=true
# mybatis传多个参数
mybatis-plus.configuration.use-actual-param-name=true
# 开启驼峰命名转换
mybatis-plus.configuration.map-underscore-to-camel-case=true
# ======================== 指定配置文件 ========================
spring.profiles.active=dev
// 开启分页
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
二、application-dev.yml
# =========================== 开发环境 ===========================
server:
port: 8508
spring:
# ========================== 应用名称 ==========================
application:
name: Sb-MulDemo
# ========================= 数据库配置 =========================
datasource:
url: jdbc:mysql://ip:3306/platform?zeroDateTimeBehavior=convertToNull&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
username: 用户名
password: 密码
# url: jdbc:oracle:thin:@ip:1521/orcl
# username: 用户名
# password: 密码
# ========================= Redis配置 ==========================
redis:
host: ip
password:
database: 12
port: 6379
# ========================== 个性化参数 ==========================
test: application-dev.yml