服务端口号:

server:
  port: 8081

Spring配置:

spring:
  datasource: #配置数据源四要素
    url: jdbc:mysql://localhost:3306/travel_heima
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
  application: #服务名称
    name: consumer-service

MyBatis配置:

mybatis:
  type-aliases-package: cn.xxx.pojo
  configuration:
    map-underscore-to-camel-case: true #开启驼峰匹配

Eureka服务配置:

eureka:
  client:
    fetch-registry: false #拉取服务
    register-with-eureka: false #注册自己
    service-url:
      defaultZone: http://127.0.0.1:10086/eureka,http://127.0.0.1:10087/eureka #集群互相注册
  instance:
    ip-address: 127.0.0.1
    instance-id: ${eureka.instance.ip-address}:${server.port}

zuul网关配置:

zuul:
  prefix: /api #前缀
  routes:
    user-service:
     path: /user/** #访问路径
     serviceId: user-service #服务id
     strip-prefix: false #是否开启前缀
  ignored-services:
    - user-service
    - consumer-feign

Ribbon负载均衡配置:

 ConnectTimeout: 500 # ribbon链接超时时长
  ReadTimeout: 2000 # ribbon读取超时时长
  MaxAutoRetries: 0  # 当前服务重试次数
  MaxAutoRetriesNextServer: 1 # 切换服务重试次数
  OkToRetryOnAllOperations: false # 是否对所有的请求方式都重试,只对get请求重试

Hystrix配置:

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 5000 # 熔断超时时长:6000ms
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐