优化共享配置
This commit is contained in:
parent
2114d6642c
commit
d40dbd43c2
|
@ -13,6 +13,9 @@ import com.recovery.common.base.util.RedisUtil;
|
|||
import com.recovery.common.base.util.UtilTools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
@ -26,6 +29,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping("/api/v1/test")
|
||||
@Slf4j
|
||||
@RefreshScope
|
||||
public class testController {
|
||||
|
||||
@Resource
|
||||
|
@ -35,6 +39,9 @@ public class testController {
|
|||
@Autowired
|
||||
private DynamicThreadPoolConfig dynamicThreadPool;
|
||||
|
||||
@Value("${sa-token.token-name}")
|
||||
private String tokenHeader;
|
||||
|
||||
/**
|
||||
* cs
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.recovery.common.base.constant.Constants;
|
|||
import com.recovery.common.base.result.ResultCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
@ -20,11 +22,14 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@RefreshScope
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
|
||||
|
||||
public JwtInterceptor() {}
|
||||
@Value("${sa-token.token-name}")
|
||||
private String tokenHeader;
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 获取当前token(这个token获取的是请求头的token,也可以用 request 获取)
|
||||
|
|
|
@ -11,71 +11,24 @@ spring:
|
|||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
metadata:
|
||||
serviceGroup: cpp
|
||||
server-addr: 192.168.110.210:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
# discovery:
|
||||
# metadata:
|
||||
# serviceGroup: cpp
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-admin
|
||||
group: dev
|
||||
prefix: ${spring.application.name}
|
||||
group: ${spring.profiles.active}
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
dynamic:
|
||||
tp:
|
||||
enabled: true
|
||||
enabledBanner: true # 是否开启banner打印,默认true
|
||||
enabledCollect: true # 是否开启监控指标采集,默认false
|
||||
collectorTypes: micrometer,logging # 监控数据采集器类型(logging | micrometer | internal_logging),默认micrometer
|
||||
logPath: /home/logs # 监控日志数据路径,默认 ${user.home}/logs,采集类型非logging不用配置
|
||||
monitorInterval: 5 # 监控时间间隔(报警判断、指标采集),默认5s
|
||||
platforms: # 通知报警平台配置
|
||||
- platform: email
|
||||
receivers: 1650611030@qq.com
|
||||
tomcatTp: # tomcat webserver线程池配置
|
||||
corePoolSize: 100
|
||||
maximumPoolSize: 200
|
||||
keepAliveTime: 60
|
||||
executors: # 动态线程池配置
|
||||
- threadPoolName: dtpExecutor
|
||||
# 线程池别名
|
||||
executorType: common # 线程池类型common、eager:适用于io密集型
|
||||
corePoolSize: 5 # 核心线程数
|
||||
maximumPoolSize: 18 # 最大线程数
|
||||
queueCapacity: 400 # 任务队列容量
|
||||
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类
|
||||
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类
|
||||
keepAliveTime: 50
|
||||
allowCoreThreadTimeOut: false # 是否允许核心线程池超时
|
||||
threadNamePrefix: test # 线程名前缀
|
||||
waitForTasksToCompleteOnShutdown: false # 参考spring线程池设计,优雅关闭线程池
|
||||
awaitTerminationSeconds: 5 # 单位(s)
|
||||
preStartAllCoreThreads: false # 是否预热所有核心线程,默认false
|
||||
runTimeout: 200 # 任务执行超时阈值,目前只做告警用,单位(ms)
|
||||
queueTimeout: 100 # 任务在队列等待超时阈值,目前只做告警用,单位(ms)
|
||||
taskWrapperNames: [ "ttl" ] # 任务包装器名称,集成TaskWrapper接口
|
||||
notifyItems: # 报警项,不配置自动会按默认值配置(变更通知、容量报警、活性报警、拒绝报警、任务超时报警)
|
||||
- type: capacity # 报警项类型,查看源码 NotifyTypeEnum枚举类
|
||||
enabled: true
|
||||
threshold: 80 # 报警阈值
|
||||
platforms: [ ding,wechat ] # 可选配置,不配置默认拿上层platforms配置的所以平台
|
||||
interval: 120 # 报警间隔(单位:s)
|
||||
- type: change
|
||||
enabled: true
|
||||
- type: liveness
|
||||
enabled: true
|
||||
threshold: 80
|
||||
- type: reject
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: run_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: queue_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
|
||||
#Nacos Config 目前提供了三种配置能力从 Nacos 拉取相关的配置
|
||||
#A: 通过 spring.cloud.nacos.config.shared-dataids 支持多个共享 Data Id 的配置
|
||||
#B: 通过 spring.cloud.nacos.config.ext-config[n].data-id 的方式支持多个扩展 Data Id 的配置
|
||||
#C: 通过内部相关规则(应用名、应用名+ Profile )自动生成相关的 Data Id 配置
|
||||
#当三种方式共同使用时,他们的一个优先级关系是:A < B < C
|
||||
# 共享的配置,比如连接池之类的 需要注意共享配置不区分环境默认就是DEFAULT_GROUP
|
||||
shared-configs: # 多微服务间共享的配置列表
|
||||
- dataId: share.yaml # 要共享的配置文件id
|
||||
refresh: true
|
||||
server:
|
||||
port: 9002
|
||||
|
||||
|
|
|
@ -12,25 +12,14 @@ spring:
|
|||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
server-addr: 192.168.110.210:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
# server-addr: 192.168.110.210:8848
|
||||
# namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-auth
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
shared-dataids: share.yaml
|
||||
server:
|
||||
port: 9001
|
||||
|
||||
|
||||
|
||||
sa-token:
|
||||
# jwt秘钥
|
||||
jwt-secret-key: asdasdasifhueuiwyurfewbfjsdafjk123
|
||||
token-name: satoken
|
||||
timeout: -1
|
||||
active-timeout: -1
|
||||
is-concurrent: false
|
||||
is-share: false
|
||||
is-log: true
|
||||
|
|
|
@ -11,13 +11,14 @@ spring:
|
|||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
server-addr: 192.168.110.210:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
# server-addr: 192.168.110.210:8848
|
||||
# namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-gateway
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
shared-dataids: share.yaml
|
||||
server:
|
||||
port: 9000
|
||||
|
|
Loading…
Reference in New Issue