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
------------ 空闲连接存活最大时间,默认600000(10分钟)
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表示无限生命周期,默认1800000即30分钟
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
[GetWay的 yml]配置的了解
最新推荐文章于 2022-05-14 17:32:57 发布