From ee30f18d53354cee52c23580c9ba1d3a586a690d Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 27 Jul 2020 14:45:53 +0800 Subject: [PATCH] 3.2.1 --- doc/docs/_sidebar.md | 74 +++++++++---------- doc/docs/files/10011_项目接入到SOP.md | 42 ++++++----- .../gateway/route/GatewayRouteRepository.java | 8 +- .../zuul/route/ZuulRouteRepository.java | 4 +- .../main/resources/application-dev.properties | 11 --- 5 files changed, 66 insertions(+), 73 deletions(-) diff --git a/doc/docs/_sidebar.md b/doc/docs/_sidebar.md index a6b48b7e..d510aa50 100644 --- a/doc/docs/_sidebar.md +++ b/doc/docs/_sidebar.md @@ -1,39 +1,39 @@ -* [首页](/?t=1591927043815) +* [首页](/?t=1595832340981) * 开发文档 - * [快速体验](files/10010_快速体验.md?t=1591927043817) - * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1591927043835) - * [新增接口](files/10020_新增接口.md?t=1591927043836) - * [开发流程](files/10021_开发流程.md?t=1591927043836) - * [业务参数校验](files/10030_业务参数校验.md?t=1591927043836) - * [错误处理](files/10040_错误处理.md?t=1591927043836) - * [编写文档](files/10041_编写文档.md?t=1591927043836) - * [接口交互详解](files/10050_接口交互详解.md?t=1591927043836) - * [easyopen支持](files/10070_easyopen支持.md?t=1591927043836) - * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1591927043836) - * [ISV管理](files/10085_ISV管理.md?t=1591927043836) - * [自定义返回结果](files/10087_自定义返回结果.md?t=1591927043837) - * [自定义过滤器](files/10088_自定义过滤器.md?t=1591927043837) - * [自定义校验token](files/10089_自定义校验token.md?t=1591927043837) - * [网关拦截器](files/10090_网关拦截器.md?t=1591927043837) - * [路由授权](files/10090_路由授权.md?t=1591927043837) - * [接口限流](files/10092_接口限流.md?t=1591927043837) - * [路由监控](files/10093_路由监控.md?t=1591927043837) - * [SDK开发](files/10095_SDK开发.md?t=1591927043837) - * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1591927043837) - * [应用授权](files/10097_应用授权.md?t=1591927043837) - * [提供restful接口](files/10100_提供restful接口.md?t=1591927043838) - * [文件上传](files/10104_文件上传.md?t=1591927043838) - * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1591927043838) - * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1591927043838) - * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1591927043838) - * [使用eureka](files/10112_使用eureka.md?t=1591927043838) - * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1591927043838) + * [快速体验](files/10010_快速体验.md?t=1595832340983) + * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1595832341000) + * [新增接口](files/10020_新增接口.md?t=1595832341000) + * [开发流程](files/10021_开发流程.md?t=1595832341001) + * [业务参数校验](files/10030_业务参数校验.md?t=1595832341001) + * [错误处理](files/10040_错误处理.md?t=1595832341001) + * [编写文档](files/10041_编写文档.md?t=1595832341001) + * [接口交互详解](files/10050_接口交互详解.md?t=1595832341001) + * [easyopen支持](files/10070_easyopen支持.md?t=1595832341001) + * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1595832341001) + * [ISV管理](files/10085_ISV管理.md?t=1595832341001) + * [自定义返回结果](files/10087_自定义返回结果.md?t=1595832341001) + * [自定义过滤器](files/10088_自定义过滤器.md?t=1595832341001) + * [自定义校验token](files/10089_自定义校验token.md?t=1595832341002) + * [网关拦截器](files/10090_网关拦截器.md?t=1595832341002) + * [路由授权](files/10090_路由授权.md?t=1595832341002) + * [接口限流](files/10092_接口限流.md?t=1595832341002) + * [路由监控](files/10093_路由监控.md?t=1595832341002) + * [SDK开发](files/10095_SDK开发.md?t=1595832341002) + * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1595832341002) + * [应用授权](files/10097_应用授权.md?t=1595832341003) + * [提供restful接口](files/10100_提供restful接口.md?t=1595832341003) + * [文件上传](files/10104_文件上传.md?t=1595832341003) + * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1595832341003) + * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1595832341003) + * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1595832341003) + * [使用eureka](files/10112_使用eureka.md?t=1595832341003) + * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1595832341003) * 原理分析 - * [网关性能测试](files/90001_网关性能测试.md?t=1591927043838) - * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1591927043838) - * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1591927043838) - * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1591927043839) - * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1591927043839) - * [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1591927043839) - * [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1591927043839) - * [常见问题](files/90100_常见问题.md?t=1591927043839) + * [网关性能测试](files/90001_网关性能测试.md?t=1595832341004) + * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1595832341004) + * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1595832341004) + * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1595832341004) + * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1595832341004) + * [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1595832341004) + * [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1595832341004) + * [常见问题](files/90100_常见问题.md?t=1595832341004) diff --git a/doc/docs/files/10011_项目接入到SOP.md b/doc/docs/files/10011_项目接入到SOP.md index b0e6af8b..7cadcae9 100644 --- a/doc/docs/files/10011_项目接入到SOP.md +++ b/doc/docs/files/10011_项目接入到SOP.md @@ -6,11 +6,13 @@ ```xml - Greenwich.RELEASE - - 0.9.0.RELEASE - - 1.1.3 + + 2.2.5.RELEASE + + Hoxton.SR3 + + + 2.2.1.RELEASE ``` @@ -19,10 +21,24 @@ ```xml + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + org.springframework.cloud spring-cloud-dependencies - Greenwich.RELEASE + ${spring-cloud.version} + pom + import + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} pom import @@ -40,28 +56,16 @@ 最新版本 - - org.springframework.cloud + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - ${spring-cloud-alibaba-nacos.version} - - - com.alibaba.nacos - nacos-client - ${nacos-client.version} - ``` - application.properties配置文件添加 ```properties server.port=2222 -# 服务名称 spring.application.name=story-service # nacos注册中心 spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java index 3f19bddb..b1aceee3 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java @@ -32,9 +32,9 @@ import static java.util.Collections.synchronizedMap; @Slf4j public class GatewayRouteRepository implements RouteRepository, RouteLocator { - private PathMatcher pathMatcher = new AntPathMatcher(); + private final PathMatcher pathMatcher = new AntPathMatcher(); - private final Map routes = synchronizedMap(new LinkedHashMap<>()); + private static final Map routes = synchronizedMap(new LinkedHashMap<>()); @Autowired private RouteLocatorBuilder routeLocatorBuilder; @@ -54,7 +54,7 @@ public class GatewayRouteRepository implements RouteRepository routeDefinitionList = this.routes.values() + List routeDefinitionList = routes.values() .stream() .map(AbstractTargetRoute::getRouteDefinition) .collect(Collectors.toList()); @@ -135,7 +135,7 @@ public class GatewayRouteRepository implements RouteRepository idList = this.routes.values().stream() + List idList = routes.values().stream() .filter(zuulTargetRoute -> StringUtils.equalsIgnoreCase(serviceId, zuulTargetRoute.getServiceRouteInfo().getServiceId())) .map(zuulTargetRoute -> zuulTargetRoute.getRouteDefinition().getId()) .collect(Collectors.toList()); diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java index e25f5aac..632cdb83 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java @@ -18,12 +18,12 @@ import java.util.stream.Collectors; */ public class ZuulRouteRepository implements RouteRepository { - private PathMatcher pathMatcher = new AntPathMatcher(); + private final PathMatcher pathMatcher = new AntPathMatcher(); /** * key:nameVersion */ - private Map nameVersionTargetRouteMap = new ConcurrentHashMap<>(128); + private static final Map nameVersionTargetRouteMap = new ConcurrentHashMap<>(128); @Override public ZuulTargetRoute get(String id) { diff --git a/sop-example/sop-story/src/main/resources/application-dev.properties b/sop-example/sop-story/src/main/resources/application-dev.properties index a6277955..8957bc3f 100644 --- a/sop-example/sop-story/src/main/resources/application-dev.properties +++ b/sop-example/sop-story/src/main/resources/application-dev.properties @@ -1,15 +1,4 @@ server.port=2222 spring.application.name=story-service -#server.servlet.context-path=/story-service -# 如果有context-path,必须配下面这句 -#spring.cloud.nacos.discovery.metadata.server.servlet.context-path=${server.servlet.context-path} # nacos注册中心 spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 - -# zipkin服务跟踪 -#spring.zipkin.base-url=http://127.0.0.1:9411/ -## 设置sleuth收集信息的比率,默认0.1,最大是1,数字越大越耗性能 -#spring.sleuth.sampler.probability=1 -## dubbo使用zipkin过滤器 -#dubbo.provider.filter=tracing -#dubbo.consumer.filter=tracing