{"id":48680710,"url":"https://github.com/smallbeanteng/dubbo-gateway","last_synced_at":"2026-04-26T20:00:41.899Z","repository":{"id":57717541,"uuid":"450453128","full_name":"smallbeanteng/dubbo-gateway","owner":"smallbeanteng","description":"dubbo-gateway 高性能dubbo网关，提供了http协议到dubbo协议的转换，同时支持REACTIVE或SERVLET类型网关或微服务项目的整合","archived":false,"fork":false,"pushed_at":"2022-03-03T15:34:59.000Z","size":259,"stargazers_count":160,"open_issues_count":0,"forks_count":44,"subscribers_count":12,"default_branch":"main","last_synced_at":"2026-01-11T19:33:51.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smallbeanteng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-21T10:46:01.000Z","updated_at":"2025-09-15T14:39:57.000Z","dependencies_parsed_at":"2022-09-10T18:03:09.500Z","dependency_job_id":null,"html_url":"https://github.com/smallbeanteng/dubbo-gateway","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/smallbeanteng/dubbo-gateway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallbeanteng%2Fdubbo-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallbeanteng%2Fdubbo-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallbeanteng%2Fdubbo-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallbeanteng%2Fdubbo-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallbeanteng","download_url":"https://codeload.github.com/smallbeanteng/dubbo-gateway/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallbeanteng%2Fdubbo-gateway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32310804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T19:15:34.056Z","status":"ssl_error","status_checked_at":"2026-04-26T19:15:15.467Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-11T01:00:36.055Z","updated_at":"2026-04-26T20:00:41.891Z","avatar_url":"https://github.com/smallbeanteng.png","language":"Java","funding_links":[],"categories":["API网关"],"sub_categories":["Spring Cloud框架"],"readme":"# dubbo-gateway #\ndubbo-gateway 高性能dubbo网关，提供了http协议到dubbo协议的转换,但【并非】使用dubbo的【泛化】调用（泛化调用性能比普通调用有10-20%的损耗,通过普通异步的调用方式与基于webflux系列的响应式网关(spring cloud gateway)整合提高系统的吞吐量,普通调用需要依赖api jar包,需要对接口定义进行改造,除此之外不需要做任何其它改造.另外也支持基于servlet类的应用或网关(spring cloud zuul)进行整合\n## 泛化缺点 ##\n- 泛化过程数据流会经过了三次转换, 会产生大量的临时对象, 有很大的内存要求。使用反射方式对于旨在榨干服务器性能以获取高吞吐量的系统来说, 难以达到性能最佳\n- 同时服务端也会对泛化请求多一重 Map \u003c-\u003e POJO 的来回转换的过程。整体上，与普通的Dubbo调用相比有10-20%的损耗\n- 泛化调用在网关或服务消费者阶段无法校验参数类型及参数的有效性，数据要到服务提供者使用阶段时才能校验出参数的有效性\n## 开源地址 ##\nhttps://github.com/smallbeanteng/dubbo-gateway\n## 相关注解 ##\n## @GateWayDubbo ##\n标识这个接口需要自动进行协议转换\n\n    /**\n\t * 服务id,可以和dubbo普通调用的配置属性关联.\n\t */\n\t@AliasFor(\"id\")\n\tString value() default \"\";\n\n\t/**\n\t * 服务id,可以和dubbo普通调用的配置属性关联.\n\t * 例如: \n\t\t\tcom.atommiddleware.cloud.config.dubboRefer.\u003cuserService\u003e.version=1.1.0\n\t\t\tcom.atommiddleware.cloud.config.dubboRefer.\u003cuserService\u003e.group=userSystem\n\t\t\t以上相当于会调用版本号为1.1.0并且groupw为userSystem的dubbo服务,与@DubboReference的参数对齐，具体支持哪些参数详见配置类DubboReferenceConfigProperties\n\t */\n\t@AliasFor(\"value\")\n\tString id() default \"\";\n## @PathMapping ##\n标记这个接口方法需要进行协议自动转换\n    \n    /**\n\t * 路径表达式\n\t */\n\t@AliasFor(\"path\")\n\tString value() default \"\";\n\n\t/**\n\t * 路径表达式\n\t */\n\t@AliasFor(\"value\")\n\tString path() default \"\";\n\t\n\t/**\n\t * 提交方法，GET或POST\n\t */\n\tRequestMethod requestMethod() default RequestMethod.POST;\n\t\n\tpublic enum RequestMethod {\n\t\tGET, POST\n\n\t}\n## @FromBody ##\n表示参数对象来源于消息体\n\n    /**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## @FromHeader ##\n表示参数对象来源于消息头\n\n    /**\n\t * 消息头名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString value() default \"\";\n\n\t/**\n\t * 消息头名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString name() default \"\";\n\t\n\t/**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## @FromCookie ##\n表示参数对象来源于cookie\n\n    /**\n\t * cookie名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString value() default \"\";\n\n\t/**\n\t * cookie名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString name() default \"\";\n\n\t/**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## @FromPath ##\n表示参数对象来源于path,支持path表达式\n\n    /**\n\t * path占位符名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString value() default \"\";\n\n\t/**\n\t * path占位符名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString name() default \"\";\n\t\n\t/**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## @FromQueryParams ##\n表示参数来源于query部分\n\n\t/**\n\t * query名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString value() default \"\";\n\n\t/**\n\t * query名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString name() default \"\";\n\t\n\t/**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## @FromAttribute ##\n表示参数来源于attribute\n\n    /**\n\t * attribute 名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString value() default \"\";\n\n\t/**\n\t * attribute 名称\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tString name() default \"\";\n\n\t/**\n\t * 是否检查参数\n\t */\n\t@AliasFor(annotation = ParamAttribute.class)\n\tboolean required() default true;\n## 配置示例 ##\n\n\t@GateWayDubbo(\"userService\")\n    public interface UserService {\n\n\t/**\n\t * hello world\n\t * @return hello\n\t */\n\t@PathMapping(value=\"/sample/helloWorld\",requestMethod=RequestMethod.GET)\n\tResult helloWorld();\n\t/**\n\t * 参数为空post请求\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/helloWorldPost\",requestMethod=RequestMethod.POST)\n\tResult helloWorldPost();\n\t/**\n\t * 返回值为空\n\t */\n\t@PathMapping(value=\"/sample/helloVoid\",requestMethod=RequestMethod.GET)\n\tvoid helloVoid();\n\t/**\n\t * 返回值为空 post请求\n\t */\n\t@PathMapping(value=\"/sample/helloVoidPost\",requestMethod=RequestMethod.POST)\n\tvoid helloVoidPost();\n\t/**\n\t * 注册用户\n\t * @param user 用户信息\n\t * @return 注册结果\n\t */\n\t@PathMapping(\"/sample/registerUser\")\n\tResult registerUser(@FromBody User user);\n\t/**\n\t * 对象数据源来自header,headerName=user,headerValue=json(UrlEncoder后的字符串)\n\t * @param user 用户信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromHeader\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromHeader(@FromHeader(value = \"user\",paramFormat = ParamFormat.JSON) User user);\n\t/**\n\t * header中以key value方式传递对象参数,headerName=headerValue转换为beanPropertyName=beanPropertyValue\n\t * headerName 对应bean 的propertyName,headerValue对应bean的propertyValue\n\t * @param user 用戶信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromHeaderMap\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromHeaderMap(@FromHeader(value=\"user\",paramFormat =ParamFormat.MAP) User user);\n\t/**\n\t * 对象数据源来自cookie,cookieName=user,cookieValue=json(UrlEncoder后的字符串)\n\t * @param user 用户信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromCookie\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromCookie(@FromCookie(value=\"user\",paramFormat = ParamFormat.JSON) User user);\n\t/**\n\t * cookie中以 key value 方式传递对象参数,cookieName=cookieValue转化为beanPropertyName=beanPropertyValue\n\t * cookieName 对应bean 的propertyName,cookieValue对应bean的propertyValue,不支持嵌套对象转换，嵌套对象或复杂参数请用json\n\t * @param user 用戶信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromCookieMap\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromCookieMap(@FromCookie(value=\"user\",paramFormat = ParamFormat.MAP) User user);\n\t/**\n\t * 对象数据源来自path,{user}=json(UrlEncoder后的字符串)\n\t * @param user 用户信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromPath/{user}\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromPath(@FromPath(value=\"user\",paramFormat = ParamFormat.JSON) User user);\n\t/**\n\t * path pattern对应bean的属性名称\n\t * @param user 用户信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/registerUserFromPathMap/{userName}/{age}/{gender}\",requestMethod=RequestMethod.GET)\n\tResult registerUserFromPathMap(@FromPath(value=\"user\",paramFormat = ParamFormat.MAP) User user);\n\n\t/**\n\t * 对象参数来源于query json字符串,user=json(UrlEncoder后的字符串)\n\t * @param user 用户信息\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/getUserInfoFromQueryParamsParamFormatJSON\",requestMethod=RequestMethod.GET)\n\tResult getUserInfoFromQueryParamsParamFormatJSON(@FromQueryParams(value=\"user\",paramFormat = ParamFormat.JSON)User user);\n\t\n\t/**\n\t * 对象参数来源于query,以key,value方式传参,key对应bean propertyName,value对应propertyValue,嵌套对象或复杂对象请使用JSON\n\t * @param user 用户\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/getUserInfoFromQueryParamsParamFormatMap\",requestMethod=RequestMethod.GET)\n\tResult getUserInfoFromQueryParamsParamFormatMap(@FromQueryParams(value=\"user\",paramFormat = ParamFormat.MAP)User user);\n\t/**\n\t * 数据来源queryParam\n\t * @param userId 用户id\n\t * @return 取消注销结果\n\t */\n\t@PathMapping(value=\"/sample/unRegisterUser\",requestMethod=RequestMethod.GET)\n\tResult unRegisterUser(@FromQueryParams(\"userId\")Long userId);\n\t/**\n\t * 数据来源path\n\t * @param userId 用戶id\n\t * @return 结果\n\t */\n\t@PathMapping(value=\"/sample/getUserInfo/{userId}/{gender}\",requestMethod=RequestMethod.GET)\n\tResult getUserInfo(@FromPath(\"userId\") Long userId,@FromPath(\"gender\") Short gender);\n\t/**\n\t * 数据来源header 和cookie\n\t * @param userId 用户id\n\t * @param age 年龄\n\t * @return 返回查询结果\n\t */\n\t@PathMapping(value=\"/sample/getUserInfo/byHeaderAndCookie\",requestMethod=RequestMethod.GET)\n\tResult getUserInfo(@FromHeader(\"userId\")Long userId,@FromCookie(\"age\")Integer age);\n\n\t/**\n\t * 全场景\n\t * @param userId 用户id\n\t * @param age 年龄\n\t * @param gender 性别\n\t * @param user 用户信息\n\t * @return 查询结果\n\t */\n\t@PathMapping(\"/sample/getUserUserInfoAll/{userId}\")\n\tResult getUserUserInfoAll(@FromPath(\"userId\") Long userId,@FromCookie(\"age\")Integer age,@FromHeader(\"gender\")Long gender,@FromBody User user);\n}\n\n\n参数注意事项：\n\n@PathMapping参数 requestMethod：用于限定访问服务的方法，支持POST与GET,默认为POST\n\n@FromCookie、@FromPath、@FromHeader、@FromQueryParams参数 paramFormat：\n\n- JSON方式 限定参数名称对应的值为json字符串，然后通过反序列化json字符串得到参数对象(如@FromHeader(\"user\") httpHeader应该要有一个头名称为user并且值为【样例数据】的json字符串(UrlEncode))，此将入参看做一个整体json字符串\n- MAP方式 限定对象的propertyName与单个参数一一对应【例如@FromHeader(value=\"user\",paramFormat =ParamFormat.MAP) httpHeader应该要有头名称为userName、password、age、gender、dt等与User对象属性对应的头信息，User将获取这些头信息最终组装成完整对象】,此方式不支持复杂嵌套对象,复杂嵌套对象请使用json,1.1.3+版本后默认为Map方式\n- 此外如果方法的参数类型本身为基本数据类型，将固定使用Map方式，具体差异可以通过导入postman的测试用例体验\n\n## 样例数据 ##\n    {\n    \"userName\": \"admin\",\n    \"password\": \"123456\",\n\t\"age\": 99,\n\t\"gender\": 1,\n    \"dt\": 1644431796892,\n\t\"workHistory\": {\"workDescriptions\": [\"中学\",\"大学\"]} \n    }\n## 使用步骤 ##\n第一步：按照示例改造api接口，接口需要引入dubbo-gateway-api jar包\n\t\n      \t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003ecom.atommiddleware\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003edubbo-gateway-api\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e1.1.4.6-GA\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n第二步：网关引入改造后的jar包，同时引用以下jar包\n\n\t`\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003ecom.atommiddleware\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003edubbo-gateway-spring-boot-starter\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e1.1.4.6-GA\u003c/version\u003e\n\t\t\u003c/dependency\u003e`\n第三步：在启动类上添加要扫描的api包名@DubboGatewayScanner(basePackages = \"需扫描的api包名\")\n\n第四步: 网关配置routes（-\u003e看【配置中心】说明），如果只是单独的spring mvc则不需要配置了\n\n第五步：没了...就是这么简单\n## 项目说明 ##\n- dubbo-gateway-api 是核心的api，相关注解都是在此项目中定义\n- dubbo-gateway-core 核心实现，实现dubbo-gateway的相关逻辑都在此项目中\n- dubbo-gateway-spring-boot-autoconfigure dubbo-gateway的自动装配\n- dubbo-gateway-spring-boot-starter dubbo-gateway的starter\n- dubbo-gateway-sample-api 示例服务api定义在此项目中\n- dubbo-gateway-sample-provider 基于spring cloud的dubbo 服务提供者示例\n- dubbo-gateway-sample 基于webflux(spring cloud gateway)的接入dubbo-gateway示例\n- dubbo-gateway-sample-web-provider 基于sevlet类型的dubbo服务提供者示例\n- dubbo-gateway-sample-web-consumer 基于sevlet类型spring mvc的项目接入dubbo-gateway示例\n- dubbo-gateway-sample-zuul 基于spring cloud zuul 接入dubbo-gateway示例\n- dubboGateWay.postman_collection.json 导出的一份postman自测用例\n- dubboGateWay_XSS.postman_collection.json 导出的一份包含xss攻击代码的自测用例\n## 配置中心 ##\n按照dubbo的正常接入配置进行配置就好了，以下贴出例子使用的配置在nacos配置中心的配置,其中filters使用了Dubbo作为过滤器\n\n服务提供者配置:\n\n    dubbo:\n      protocol:\n        name: dubbo\n        port: 20861\n    server:\n      port: 8861\n    spring:\n      cloud:\n        nacos:\n          discovery:\n            namespace: dev\n            server-addr: 127.0.0.1:8848\n整合spring cloud gateway 网关配置：\n    \n    dubbo:\n      cloud:\n        subscribed-services: dubbo-gateway-sample-provider\n    server:\n      port: 8862\n    spring:\n      cloud:\n        nacos:\n          discovery:\n            namespace: dev\n            server-addr: 127.0.0.1:8848\n        gateway:\n          routes:\n          - id: myGateway\n            uri: dubbo://127.0.0.1:8862\n            predicates:\n            - Path=/**\n\n整合spring cloud zuul网关配置:\n\n\n    dubbo:\n      cloud:\n        subscribed-services: dubbo-gateway-sample-provider\n    server:\n      port: 8862\n    spring:\n      cloud:\n        nacos:\n          discovery:\n            namespace: dev\n            server-addr: 127.0.0.1:8848\n      main:\n        allow-bean-definition-overriding: true\n    zuul:\n\t  ignored-patterns: /favicon.ico,/cas/redirect\n      routes:\n        dubboService:\n          stripPrefix: false\n          url: dubbo://127.0.0.1\n          path: /**\n注意：配置中的\"D(d)ubbo\"子眼表示使用的是dubbo gateway相关功能去处理路由，如果不配置则不会生效.\n其中配置中uri(l) 配置除了dubbo相关字眼，其它信息并无实际意义，只是为了符合网关的配置规范要求，可以配成127.0.0.1等\n\n整合spring mvc 配置：\n\n    com.atommiddleware.cloud.config.includUrlPatterns=/sample/*,/order/*\n    com.atommiddleware.cloud.config.excludUrlPatterns=\n\nincludUrlPatterns参数用于配置需要进行协议转换的url，excludUrlPatterns用于排除个别url,这两个参数只对【非】网关整合有效(因与网关整合path匹配交给了网关的path参数进行匹配)\n## 安全 ##\nxss防御 1.1.1版本+\n\n参数校验组件 1.1.2版本+\n\ncas 认证登录 1.1.3-beta+ spring mvc 与zuul 集成了spring security cas认证与spring session\n\n配置:\n\t\n    com:\n      atommiddleware:\n        cloud:\n          config:\n            security:\n              cas:\n                 enable: true\n                 baseUrl: https://cas.atommiddleware.com:8812/sys/menusAndPermissions\n                 serverUrl: https://cas.atommiddleware.com:8443/cas\n                 principalAttrs: userId,companyCode,isSuperAdmin,username\n                 ignoringUrls:\n                 permitUrls:\n                 anonymousUrls:\n              xss:\n                 enable: true\n                 filterStrategy: 0\n                 filterMode: 0\n                 antisamyFileLocationPattern:\n              csrf:\n                 enable: false\n\t             domain: atommiddleware.com\n\t             path: /\n\t          cors:\n\t             enable: true\n\t             allowedOrigins: https://admin.atommiddleware.com:9628\n\t             allowedHeaders: X-Requested-With,content-type,X-XSRF-TOKEN\n\t             allowedMethods: GET,POST\n\t             maxAge: 3600 \n            session:\n              cookie:\n                 enable: true\n                 domain: atommiddleware.com\n                 name: atomSessionId\n                 path: /\n\n## cas认证 ##\n\t\n\tcas认证中心开源传送门:https://github.com/apereo/cas\n开启步骤:\n\n\t引入jar包:spring-boot-starter-security,spring-security-cas\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003espring-boot-starter-security\u003c/artifactId\u003e\n\t\t\u003c/dependency\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.springframework.security\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003espring-security-cas\u003c/artifactId\u003e\n\t\t\u003c/dependency\u003e\n\t实现自己的用户定义，用户转换，权限逻辑主要有以下几个类需要实现\n用户定义：org.springframework.security.core.userdetails 用户信息需要哪些属性\n用户转换:com.atommiddleware.cloud.security.cas.CustomUserDetailsService 此类是默认实现，需要自己实现从cas认证中心登录成功后获取到的用户信息，转换为上一步的用户定义，如果是基于Url的权限定义可以使用com.atommiddleware.cloud.security.cas.PathPatternGrantedAuthority作为权限的载体，该类实现了match方法可以对url是否符合权限进行判断\n权限逻辑:com.atommiddleware.cloud.security.cas.BasedVoter 实现对权限控制的逻辑，上一步用户转换可以给用户定义此登录用户的权限信息,在这一步可以获取到用户的权限信息，并加上验证逻辑\n\n写好以上逻辑后上述类配置在Configuration中并且自定义实现在@AutoConfigureBefore(CasSecurityAutoConfiguration.class) 加载即可,再到spring.factories配置好此配置类\n\n例子:\n\n\t@Configuration(proxyBeanMethods = false)\n    @AutoConfigureBefore(CasSecurityAutoConfiguration.class)\n    public class MyAutoConfiguration {\n\n\t@Bean\n\t@ConditionalOnMissingBean\n\tpublic BasedVoter basedVoter() {\n\t\treturn new 自定义的BasedVoter;\n\t}\n\n\t@Bean\n\t@ConditionalOnMissingBean\n\tpublic CustomUserDetailsService customUserDetailsService() {\n\t\treturn new 自定义的CustomUserDetailsServce;\n\t}\n    }\n\n在spring.factories中添加:\n\n\torg.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n    \u003c包名\u003e.MyAutoConfiguration\t\n\n \n参数配置说明:\n![图片丢失了...](http://www.atommiddleware.com/cas.png)\n\n## xss防御 ##\n  参数配置说明:\n![图片丢失了...](http://www.atommiddleware.com/xss.png)\n\n## 参数校验 ##\n  交给hibernate-validator框架注解配置\n\n## csrf防御 ##\n  参数配置说明\n![图片丢失了...](http://www.atommiddleware.com/csrf.png)\n\n## cors ##\n  参数配置说明\n![图片丢失了...](http://www.atommiddleware.com/cors.png)\n\n## session共享 ##\n\n开启步骤:\n\n\t引入jar包:spring-boot-starter-data-redis,spring-session-data-redis,commons-pool2\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003espring-boot-starter-data-redis\u003c/artifactId\u003e\n\t\t\u003c/dependency\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.springframework.session\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003espring-session-data-redis\u003c/artifactId\u003e\n\t\t\u003c/dependency\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.apache.commons\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003ecommons-pool2\u003c/artifactId\u003e\n\t\t\u003c/dependency\u003e\n\n  参数配置说明:\n![图片丢失了...](http://www.atommiddleware.com/session.png)\n\n参数校验示例:\n    \n    public class Order implements Serializable {\n\n\tprivate static final long serialVersionUID = 1L;\n\t@NotBlank(message = \"订单号不能为空\")\n\tprivate String orderCode;\n\n\tpublic String getOrderCode() {\n\t\treturn orderCode;\n\t}\n\n\tpublic void setOrderCode(String orderCode) {\n\t\tthis.orderCode = orderCode;\n\t}\n\n    }\n\n## 序列化 ##\n接口：com.atommiddleware.cloud.core.serialize\njson序列化默认采用的是jackson,如果需要定制可以自行定制实现\n## 输出响应 ##\nspring cloud gateway类型接口:com.atommiddleware.cloud.core.annotation.ResponseReactiveResult\n\nspring mvc 类型接口:com.atommiddleware.cloud.core.annotation.ResponseServletResult\n\nspring cloud zuul类型接口:com.atommiddleware.cloud.core.annotation.ResponseZuulServletResult\n\n默认实现添加了一些简单的头信息，如果需要定制实现可以自行实现接口\n\n## 错误码表 ##\n- 404 匹配的地址在dubbo未发现对应的服务\n- 415 不支持的Media Type,默认支持[application/json,application/x-www-form-urlencoded]\n- 500 内部服务器错误，一般为调用的dubbo服务抛出了异常或其它\n- 405 方法不允许,默认只支持[post,get],并且要与@PathMapping的requestMethod参数匹配\n- 400 错误的请求，一般情况是参数校验未通过\n- 其它对照HttpStatus \n\n## 其它说明 ##\n基于webflux的网关与基于servlet类的web应用接入整合方式是一样的步骤，例子使用的nacos版本2.0.3，默认支持GET,POST方式接入，ContentType支持application/json，application/x-www-form-urlencoded，复杂参数【类的属性为非基本数据类型】建议使用application/json,或项目整体都使用application/json\n## 版本说明 ##\n推荐试用1.1.4.6-GA\n## feature ##\n- spring cloud gateway 的安全实现【最好对接cas server】\n- api jar包的热部署实现\n- 实现根据元数据中心dubbo泛化调用\n- multimap转bean高性能实现【解决复杂表单转复杂bean的场景(ContentType为application/x-www-form-urlencoded时的复杂表单)】 \n\n## 招募 ##\n欢迎对微服务相关技术有研究并且热爱技术的兄弟加入此项目的开源队伍.\n\n![图片不见了...](http://www.atommiddleware.com/author12.jpg)\n\n## 打赏 ##\n您的支持是一种动力.哈哈\n\n![图片消失了...](http://www.atommiddleware.com/authorpay1.jpg)\n    ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallbeanteng%2Fdubbo-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallbeanteng%2Fdubbo-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallbeanteng%2Fdubbo-gateway/lists"}