[GetWay的 yml]配置的了解



spring:
  application:
    name: api-gateway
    #数据源配置
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    #成都测试
    url: jdbc:mysql://127.0.0.1:3306/tft?useUnicode=true&characterEncoding=UTF8&useSSL=false
    username: AAA
    password: aaa
    #华为云测试
 ----------------------------------------------------------------
		数据源配置:
    hikari:
      read-only: false
      connection-timeout: 60000
      idle-timeout: 60000
      max-lifetime: 60000
      maximum-pool-size: 30
      minimum-idle: 10
      connection-test-query: SELECT 1 from Dual
      validation-timeout: 3000

  Hikari 连接池配置 ------ 详细配置请访问:https://github.com/brettwooldridge/HikariCP
---------------最小空闲连接数量
spring.datasource.hikari.minimum-idle=5
------------ 空闲连接存活最大时间,默认60000010分钟)
spring.datasource.hikari.idle-timeout=180000
-------------- 连接池最大连接数,默认是10
spring.datasource.hikari.maximum-pool-size=10
----------------此属性控制从池返回的连接的默认自动提交行为,默认值:true
spring.datasource.hikari.auto-commit=true
------------------ 连接池名称
spring.datasource.hikari.pool-name=MyHikariCP
---------------- 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认180000030分钟
spring.datasource.hikari.max-lifetime=1800000
--------------------- 数据库连接超时时间,默认30秒,即30000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
 

 

-------------------------------------------------------------
  jpa配置,实体类自动生成数据ku表 
  dialect是方言  需要特别注意
[使用场景](           https://blog.csdn.net/sqL520lT/article/details/115459422    )
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update
    open-in-view: true
    properties:
      hibernate:
        dialect: cn.bsit.gateway.config.MySQLConfig

--------------------------------------------------------

防止实例名冲突
[使用场景](      https://blog.csdn.net/sqL520lT/article/details/115538340             )
  jmx:
    default-domain: api-gateway
    -------------------------------------------------------------
  thymeleaf:
    prefix: templates/
    suffix: .html
--------------------------------------------------------------------------

[网关+NGinx的使用场景] (  https://blog.csdn.net/sqL520lT/article/details/115306223   ) 
  cloud:
    gateway:
      discovery:
        locator:
          # true,表示gateway开启服务注册和发现的功能
          enabled: true
          # 将请求路径上的服务名配置为小写
          lower-case-service-id: true
      routes:
        - id: device-manage-api
          # lb代表从注册中心获取服务
          uri: lb://device-manage
          order: 0
          predicates:
            - Path=/device_manage/**
          filters:
            - StripPrefix=0
            - RequestTime=true
            - name: Hystrix
              args:
                name: datafallbackcmd
                fallbackUri: forward:/device_fallback
            - name: Retry
              args:
                retries: 2
                statuses: BAD_GATEWAY
        - id: auth-service-api
            # lb代表从注册中心获取服务
          uri: lb://auth-service
          order: 0
          predicates:
            - Path=/auth_service/**
          filters:
            - StripPrefix=0
            - RequestTime=true
            - name: Hystrix
              args:
                name: authfallbackcmd
                fallbackUri: forward:/auth_fallback 
            - name: Retry
              args:
                retries: 2
                statuses: BAD_GATEWAY
        - id: order-service-api
            # lb代表从注册中心获取服务
          uri: lb://order-service
          order: 0
          predicates:
            - Path=/order_service/**
          filters:
            - StripPrefix=0
            - RequestTime=true
            - name: Hystrix
              args:
                name: authfallbackcmd
                fallbackUri: forward:/order_fallback
            - name: Retry
              args:
                retries: 2
                statuses: BAD_GATEWAY

hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 31000
-----------------------------------------------------------------------------------
server:
  #本地测试
#  port: 9001
  #正式
  port: 19001
  servlet:
    context-path: /gateway

eureka:
  client:
    service-url:
#      defaultZone: http://localhost:9000/eureka_server/eureka/
      defaultZone: http://localhost:19000/eureka_server/eureka/
  instance:
    ip-address: 127.0.0.1
    prefer-ip-address: true
    instance-id: ${eureka.instance.ip-address}:${spring.application.name}:${server.port}    这个是注册中心在 eureka页面的时候 在栏中  可以清楚看见这个服务对应的端口 和IP 地址  实例名称
-------------------------------------------------------------------

这个是端口暴露,CORS通讯使用的   主要用于跨域 这里

management:
  endpoints:
    web:
      cors:
        allowed-origins: http://localhost:${server.port}
        allowed-headers: "x-requested-with,accept,cookie,content-type,ACCESS_TOKEN"
        allowed-methods: "GET, POST"
        max-age: 3600
        
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是汤圆丫

怎么 给1分?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值