当前位置: 首页 > news >正文

手机模板网站模板免费下载怎样提高网站的流量

手机模板网站模板免费下载,怎样提高网站的流量,wordpress防淘宝主题,wordpress什么读背景#xff1a;本想找个简单例子看下#xff0c;无奈版本依赖太过复杂#xff0c;花了点时间。记录下吧 使用Spring Cloud Gateway作为网关服务#xff0c;Nacos作为注册中心#xff0c;实现对子服务的负载均衡访问。简单例子。 一、gateway-main-nacos服务端#xff…背景本想找个简单例子看下无奈版本依赖太过复杂花了点时间。记录下吧 使用Spring Cloud Gateway作为网关服务Nacos作为注册中心实现对子服务的负载均衡访问。简单例子。 一、gateway-main-nacos服务端      完整pom文件 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.example/groupIdartifactIdgateway-main-nacos/artifactIdversion1.0.0/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.5.4/versionrelativePath/ !-- lookup parent from repository --/parentdependencies!-- Spring Cloud Gateway --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-gateway/artifactId/dependency!-- Nacos Discovery --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactIdversion2021.1/version/dependency!-- Nacos Config --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-config/artifactIdversion2021.1/version/dependency!-- Spring Boot Starter Web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-loadbalancer/artifactId/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion2020.0.3/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagement /project完整的yml配置文件 server:port: 8888 spring:application:name: gateway-servicemain:web-application-type: reactivecloud:nacos:discovery:server-addr: localhost:8848 # Nacos 服务器地址namespace: namespace_xxxconfig:server-addr: localhost:8848 # Nacos 配置中心地址file-extension: yamlgateway:discovery:locator:enabled: trueroutes:- id: neo_routeuri: http://www.ityouknow.compredicates:- Path/spring-cloud # - id: add_request_parameter_route # uri: http://localhost:8889 # filters: # - AddRequestParameterfoo, bar # predicates: # - MethodGET- id: lb_nacosuri: lb://user-service #会进行服务负载均衡filters:- AddRequestParameterfoo, bar123predicates:- Path/user/** # 匹配 /user/** 路径的请求- id: lb_nacos01uri: lb://user-servicefilters:- StripPrefix1 # 去掉前缀 /user01predicates:- Path/user01/** # 匹配 /user01/** 路径的请求 GatewayApplication启动类: package com.neo;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;SpringBootApplication EnableDiscoveryClient public class GatewayApplication {public static void main(String[] args) {SpringApplication.run(GatewayApplication.class, args);} }二、  路由的子服务(可以发布两个服务达到负载均衡的效果)    完整pom文件 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.example/groupIdartifactIduser-service/artifactIdversion1.0.0/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.5.4/versionrelativePath/ !-- lookup parent from repository --/parentdependencies!-- Spring Boot Starter Web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- Nacos Discovery --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactIdversion2021.1/version/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bootstrap/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-loadbalancer/artifactId/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion2020.0.3/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagement /project完整的yml文件 server:port: 8889spring:application:name: user-service#main:# web-application-type: reactivecloud:gateway:discovery:locator:enabled: truenacos:discovery:server-addr: localhost:8848 # Nacos 服务器地址namespace: namespace_xxx #nacos命名空间修改为自己定义的config:server-addr: localhost:8848 # Nacos 配置中心地址namespace: namespace_xxxfile-extension: yaml 子服务启动类: import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;SpringBootApplication EnableDiscoveryClient public class UserServiceApplication {public static void main(String[] args) {SpringApplication.run(UserServiceApplication.class, args);} } 对应测试的Controller类 ​ RestController public class HelloController {GetMapping(/hello)public String index() {return hello world!;}GetMapping(/user/hello)public String indexUser() {return hello world user!;}RequestMapping(/user/foo)public String foo(String foo) {return hello foo!;}}​ 三、测试 本地启动gateway-main-nacos、user-service、user-service-1。 访问 http://localhost:8888/user/hello多次访问发现会返回 hello world user! 或者 hello world user,another!。达到负载均衡的效果。 访问这个地址也可以看到同样的效果 http://localhost:8888/user01/hello 两个url不同的路由匹配规则。 四、遇到的问题 1.#允许bean Service循环依赖 spring.main.allow-circular-referencestrue 2.#Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway. #同时使用Spring MVC和Spring Cloud Gateway spring.main.web-application-typereactive 3.SpringCloud-Gateway搭配服务注册Nacos进行lb动态路由遇到的问题 高版本的spring-cloud-alibaba-dependencies依赖中去除了ribbon依赖若想能通过Gateway网关找到对应的微服务需要引入loadbalancer依赖。 dependency     groupIdorg.springframework.cloud/groupId     artifactIdspring-cloud-starter-loadbalancer/artifactId /dependency 参考的文档http://www.ityouknow.com/springcloud/2019/01/19/spring-cloud-gateway-service.html 源码地址https://github.com/tracysw/Spring-Cloud-Gateway-Samples
http://www.hkea.cn/news/14502786/

相关文章:

  • 郑州做网站的公司msgg建设 银行网网站
  • 上海网站建设套餐网站建设都有那些费用
  • 网站建设中的时尚资讯安徽网站备案
  • 建设返利优惠券网站宁晋网站开发搭建
  • 学做预算有网站吗华夏名网网站建设教程
  • 如何建立一家公司网站铁道部建设管理司网站
  • 网上购物有哪些网站?最好的wordpress
  • 网站建设用户体验徐州市住房建设局网站
  • 电子商务平台(网站)建设方式免费域名申请网站大全
  • 网站建设基础策划网站建设中国十强
  • 做任务的奖金网站重庆市建设工程信息网行业协会
  • 优享揭阳网站建设商务网站建设实训过程
  • 网站如何做自适应网站开发和设计如何合作
  • 医院网站和公众号建设方案wordpress loginview
  • 网站后台无法访问o2o有哪些电商平台
  • 建设什么网站挣钱用jsp和mysql做网站
  • 多个网站给一个网站推广百度竞价广告代理
  • 网站建设 博采网络 学校php cms
  • 网站的结构与布局优化网站建设方案书 5个备案
  • 奇葩网站100个卓越高职院建设网站
  • 建设银行网站查询房贷信息网页编辑哪个键
  • 网站改版如何做301网站建设解决方案服务商
  • 网站icp备案网址互联网推广品牌
  • 东莞高端品牌网站建设网址大全123上网导航
  • 网站建设需要金额默认网站停止
  • 谁能给我一个网站谢谢河南app软件开发价位
  • 哪个网站可以做兼职讲师虚拟资源交易平台Wordpress源码
  • 色弱可以做网站开发吗免费企业网站开发
  • 云南省玉溪市建设局官方网站家居网站建设行业现状
  • 网站做sem推广时要注意什么网站建设系统服务机构