springboot项目配置文件汇总(待完善)

springboot项目配置文件

一.application.yml 和 application.properties区别

1.properties文件的优先级高于yml文件

即如果两个文件中都配置了端口号,只有properties中的端口号有效,而yml文件中端口配置无效。

2.书写方式不一样

.properties方式如下:

#加载Mybatis配置文件
mybatis.mapper-locations = classpath:mapper/*Mapper.xml

.yml方式如下:

#加载Mybatis配置文件(注意空格)
mybatis:
  mapper-locations: classpath:mapper/*Mapper.xml

二.配置文件总结

#激活(选择)dev
spring.profiles.active=dev 

#端口号,不配置,默认为8080
server.port=8080

#数据库 必填项
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/yydemo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=123456

#Mybatis部分
#加载Mybatis配置文件
mybatis.mapper-locations = classpath:mapper/*Mapper.xml
#数据库驼峰命名开启,开启后,实体类中驼峰命名的字段才能接收数据库信息
mybatis.configuration.mapUnderscoreToCamelCase=true


#选填
# 最长等待毫秒数.
spring.datasource.tomcat.max-wait=10000
#最大连接数.
spring.datasource.tomcat.max-active=50
#连接前签证
spring.datasource.tomcat.test-on-borrow=true

 

#日志级别.controller为路径
logging.level.controller=trace


# redis集成 (Redis 配置)
# 连接工厂使用的数据库索引
spring.redis.database= 0
# Redis服务器主机
spring.redis.host= localhost
# 登录redis服务器的密码
spring.redis.password= 
# 给定时间池可以分配的最大连接数 使用负值为无限制
spring.redis.pool.max-active= 8
# 池中“空闲”连接的最大数量 使用负值来表示无限数量的空闲连接
spring.redis.pool.max-idle= 8
# 连接分配在池耗尽之前在抛出异常之前应阻止的最大时间量(以毫秒为单位) 使用负值无限期地阻止
spring.redis.pool.max-wait= -1
# 定义池中维护的最小空闲连接数 此设置只有在正值时才有效果
spring.redis.pool.min-idle= 0
# redis服务器端口
spring.redis.port= 6379
# redis服务器名称
spring.redis.sentinel.master=
# 连接超时(毫秒)
spring.redis.timeout= 0
发布了31 篇原创文章 · 获赞 3 · 访问量 890

猜你喜欢

转载自blog.csdn.net/S_L__/article/details/104198022