common.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # 所有服务和环境下都不变的配置
  2. # 个性化配置:复制本配置到 {服务}-${profiles.active}.yml 文件中进行修改
  3. shoulder:
  4. application:
  5. id: ${spring.application.name}
  6. # errorCodePrefix: # 每个应用唯一
  7. # version: # 从 pom.xml 获取
  8. # dateFormat: "yyyy-MM-dd'T'HH:mm:ss.SSS Z" # 默认 yyyy-MM-dd'T'HH:mm:ss.SSS Z
  9. defaultLocale: zh_CN
  10. charset: UTF-8
  11. cluster: false
  12. # 服务器配置
  13. server:
  14. undertow:
  15. io-threads: 8 # 线程数, 主要执行非阻塞的任务。推荐与 CPU 核数相同
  16. worker-threads: 120 # 阻塞任务线程池, 执行类似servlet请求阻塞操作。推荐为 CPU 核数 * 8
  17. buffer-size: 1024 # 用于服务器连接的IO操作,类似netty的池化内存管理。推荐略大于绝大多数请求的大小(根据自己的实际场景决定)
  18. direct-buffers: true # 是否分配的直接内存(堆外内存,避免 GC、复制)。推荐开启
  19. spring:
  20. # servlet 配置
  21. servlet:
  22. multipart:
  23. max-file-size: 128MB # 上传文件最大大小,默认1M
  24. max-request-size: 128MB # 请求最大大小,默认10M
  25. # http 配置
  26. http:
  27. encoding:
  28. charset: ${shoulder.application.charset} # 使用统一编码
  29. force: true
  30. enabled: true
  31. zipkin:
  32. sender:
  33. type: RABBIT
  34. enabled: ${shoulder.zipkin.enabled}
  35. discoveryClientEnabled: true
  36. baseUrl: http://localhost:9411/ #http://shoulder-zipkin:8772/
  37. compression: # 压缩
  38. enabled: true
  39. locator: # 通过 nacos 动态获取地址
  40. discovery:
  41. enabled: true
  42. rabbitmq: # 使用指定的队列
  43. queue: shoulder_zipkin
  44. # 采集率,默认 0.1 (记录 10% 的请求,过高会影响性能)
  45. sleuth:
  46. enabled: ${shoulder.zipkin.enabled}
  47. sampler:
  48. probability: 1.0
  49. # 健康检查
  50. management:
  51. endpoints:
  52. web:
  53. base-path: /actuator
  54. exposure:
  55. include: '*'
  56. endpoint:
  57. health:
  58. show-details: ALWAYS
  59. enabled: true
  60. # Feign 配置
  61. feign:
  62. httpclient:
  63. enabled: false
  64. okhttp:
  65. enabled: true
  66. hystrix:
  67. enabled: true # 开启熔断机制
  68. compression: # 压缩请求
  69. request:
  70. enabled: true
  71. mime-types: text/xml,application/xml,application/json
  72. min-request-size: 2048
  73. response: # 响应压缩
  74. enabled: true
  75. # ribbon 配置
  76. ribbon:
  77. httpclient:
  78. enabled: false
  79. okhttp:
  80. enabled: true
  81. ReadTimeout: 30000 # 响应流读取超时时间,
  82. ConnectTimeout: 30000 # 注意:要小于熔断超时时间,否则将被熔断
  83. MaxAutoRetries: 0 # 最大自动重试次数(不切换服务地址)
  84. MaxAutoRetriesNextServer: 2 # 最大自动服务地址切换重试次数
  85. OkToRetryOnAllOperations: false #无论是请求超时或者socket read timeout都进行重试,
  86. # 统一日志记录位置
  87. logging:
  88. file:
  89. path: /logs
  90. name: ${logging.file.path}/${spring.application.name}/${spring.application.name}.log