spring:
application:
name: ace-auth //应用名称
jackson:
date-format: yyyy-MM-dd HH:mm:ss //时间格式化
time-zone: GMT+8 //时区
default-property-inclusion: non_null //属性为空不序列化
redis:
database: 2
host: ${REDIS_HOST:localhost}
port:
R
E
D
I
S
P
O
R
T
:
6379
p
o
o
l
:
m
a
x
−
a
c
t
i
v
e
:
20
d
a
t
a
s
o
u
r
c
e
:
n
a
m
e
:
t
e
s
t
u
r
l
:
j
d
b
c
:
m
y
s
q
l
:
/
/
{REDIS_PORT:6379} pool: max-active: 20 datasource: name: test url: jdbc:mysql://
REDISPORT:6379pool:max−active:20datasource:name:testurl:jdbc:mysql://{MYSQL_HOST:localhost}?{MYSQL_PORT:3306}/ag_auth_v1?useUnicode=true&characterEncoding=UTF8
username: root
password: 123456
# 使用druid数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
filters: stat //属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有:
监控统计用的filter:stat日志用的filter:log4j防御sql注入的filter:wall
maxActive: 20
initialSize: 1 //连接初始值,连接池启动时创建的连接数量的初始值
maxWait: 60000 //最大等待时间
minIdle: 1 // 最小连接池数量
timeBetweenEvictionRunsMillis: 60000//配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
minEvictableIdleTimeMillis: 300000//配置一个连接在池中最小生存的时间,单位是毫秒
validationQuery: select ‘x’ //用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会其作用。
testWhileIdle: true //建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
testOnBorrow: false //申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
testOnReturn: false //归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能
poolPreparedStatements: true //是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。
maxOpenPreparedStatements: 20 //要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100
rabbitmq://消息队列
host: ${RABBIT_MQ_HOST:localhost}
port: ${RABBIT_MQ_PORT:5672}
username: guest
password: guest
sleuth:// 日志跟踪
enabled: true //表示当前程序使用sleuth
http:
legacy:
enabled: true
cloud:
consul:// 是一个支持多数据中心分布式高可用的服务发现和配置共享的服务软件,采用 Go 语言开发。
enabled: true
host: 127.0.0.1
port: 8500
discovery:
healthCheckPath: /actuator/health //HTTP健康检测
healthCheckInterval: 5s //健康检测的时间间隔
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}} //使Consul实例ID唯一
register: true
enabled: true
mybatis:
basepackage: com.github.wxiaoqi.security.auth.mapper
xmlLocation: classpath:mapper/**/.xml
mapper-locations: "classpath:mapper/*.xml"
server:
port: 9777 #启动端口
feign:
httpclient:
enabled: false
okhttp:
enabled: true
ribbon: //实现客户端的负载均衡,负载均衡器提供很多对http和tcp的行为控制。Spring cloud Feign已经集成Ribbon,所以注解@FeignClient的类,默认实现了ribbon的功能。
eureka:
enabled: true
ReadTimeout: 60000 连接超时时间
ConnectTimeout: 60000 //建立连接超时时间
MaxAutoRetries: 0
#单个节点重试最大值
MaxAutoRetriesNextServer: 1//重试发生,更换节点数最大值
OkToRetryOnAllOperations: false //所有操作都重试
hystrix: //断路器
threadpool:
default:
coreSize: 1000 ##并发执行的最大线程数,默认10
maxQueueSize: 1000 ##BlockingQueue的最大队列数
queueSizeRejectionThreshold: 500 ##即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000 //超时时间
eureka:
instance:
statusPageUrlPath: /actuator/info //状态页面的URL,相对路径,默认使用 HTTP 访问,如果需要使用 HTTPS则需要使用绝对路径配置
healthCheckUrlPath: /actuator/health //健康检查页面的URL,相对路径,默认使用 HTTP 访问,如果需要使用 HTTPS则需要使用绝对路径配置
# docker 部署开启
prefer-ip-address: true ///不使用主机名来定义注册中心的地址,而使用IP地址的形式,如果设置了eureka.instance.ip-address 属性,则使用该属性配置的IP,否则自动获取除环路IP外的第一个IP地址
ip-address: 127.0.0.1 //IP地址
client:
serviceUrl:
#defaultZone: http://localhost:8761/eureka/
# docker 部署开启
defaultZone:http://
E
U
R
E
K
A
H
O
S
T
:
l
o
c
a
l
h
o
s
t
:
{EUREKA_HOST:localhost}:
EUREKAHOST:localhost:{EUREKA_PORT:8761}/eureka/ //服务地址
jwt:
token-header: Authorization //头部token
expire: 14400 //到期时间
rsa-secret: xx1WET12%3(WE45 //秘钥
client:
id: ace-auth
secret: 123456
token-header: x-client-token
expire: 14400
rsa-secret: x2318^^(*WRYQWR(QW&T
logging:
level:
# tk.mybatis: DEBUG
com.github.wxiaoqi.security.auth: DEBUG
management:
endpoints:
web:
exposure:
include: ‘*’
security:
enabled: false //暴露所有端点.它的主要作用是用于监控与管理,它就是:spring-boot-starter-actuator。