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

企业网页建设东莞seo优化平台

企业网页建设,东莞seo优化平台,网页qq登录每一天乐在沟通,深圳企业网站制作哪家好TOC 问题背景 从零开始学springcloud微服务项目 注意事项#xff1a; 约定 配置 编码IDEA版本2021.1这个项目#xff0c;我分了很多篇章#xff0c;每篇文章一个操作步骤#xff0c;目的是显得更简单明了controller调service#xff0c;service调dao默认安装ngi… TOC 问题背景 从零开始学springcloud微服务项目 注意事项 约定 配置 编码IDEA版本2021.1这个项目我分了很多篇章每篇文章一个操作步骤目的是显得更简单明了controller调serviceservice调dao默认安装nginx项目源码以及sentinel安装包 sentinel整合ribbonopenFeignfallback 1 新建两个payment微服务module 2 选择jdk1.8 3 输入服务名cloudalibaba-provider-payment9003 和 cloudalibaba-provider-payment9004 4 引入pom依赖cloudalibaba-provider-payment9003 和 cloudalibaba-provider-payment9004两个服务名不同 ?xml version1.0 encodingUTF-8? 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.xsdparentartifactIdspringcloud2022/artifactIdgroupIdcom.yg/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdcloudalibaba-provider-payment9003/artifactIddependencies!--SpringCloud ailibaba nacos --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactId/dependencydependency!-- 引入自己定义的api通用包可以使用Payment支付Entity --groupIdcom.yg/groupIdartifactIdcloud-api-commons/artifactIdversion${project.version}/version/dependency!-- SpringBoot整合Web组件 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency!--日常通用jar包配置--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdscoperuntime/scopeoptionaltrue/optional/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependencies/project5 添加application.yml文件cloudalibaba-provider-payment9003 和 cloudalibaba-provider-payment9004端口不同 server:port: 9003spring:application:name: nacos-payment-providercloud:nacos:discovery:server-addr: localhost:8848 #配置Nacos地址management:endpoints:web:exposure:include: *6 添加启动类cloudalibaba-provider-payment9003 和 cloudalibaba-provider-payment9004类名不同 package com.yg.springcloud;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;/*** Author suolong* Date 2022/6/22 11:33* Version 2.0*/ SpringBootApplication EnableDiscoveryClient public class PaymentMain9003 {public static void main(String[] args) {SpringApplication.run(PaymentMain9003.class, args);}}7 添加controller package com.yg.springcloud.controller;import com.yg.springcloud.entities.CommonResult; import com.yg.springcloud.entities.Payment; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;/*** Author suolong* Date 2022/6/22 11:35* Version 2.0*/ RestController public class PaymentController {Value(${server.port})private String serverPort;public static HashMapLong, Payment hashMap new HashMap();static {hashMap.put(1L, new Payment(1L, 28a8c1e3bc2742d8848569891fb42181));hashMap.put(2L, new Payment(2L, bba8c1e3bc2742d8848569891ac32182));hashMap.put(3L, new Payment(3L, 6ua8c1e3bc2742d8848569891xt92183));}GetMapping(value /paymentSQL/{id})public CommonResultPayment paymentSQL(PathVariable(id) Long id) {Payment payment hashMap.get(id);CommonResultPayment result new CommonResult(200, from mysql,serverPort: serverPort, payment);return result;} }8 创建cloudalibaba-consumer-nacos-order84微服务pom依赖 ?xml version1.0 encodingUTF-8? 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.xsdparentartifactIdspringcloud2022/artifactIdgroupIdcom.yg/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdcloudalibaba-consumer-nacos-order84/artifactIddependencies!--SpringCloud openfeign --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactId/dependency!--SpringCloud ailibaba nacos --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactId/dependency!--SpringCloud ailibaba sentinel --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-sentinel/artifactId/dependency!-- 引入自己定义的api通用包可以使用Payment支付Entity --dependencygroupIdcom.yg/groupIdartifactIdcloud-api-commons/artifactIdversion${project.version}/version/dependency!-- SpringBoot整合Web组件 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency!--日常通用jar包配置--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdscoperuntime/scopeoptionaltrue/optional/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependencies/project9 添加application.yml文件 server:port: 84spring:application:name: nacos-order-consumercloud:nacos:discovery:server-addr: localhost:8848sentinel:transport:#配置Sentinel dashboard地址dashboard: localhost:8080#默认8719端口假如被占用会自动从8719开始依次1扫描,直至找到未被占用的端口port: 8719#消费者将要去访问的微服务名称(注册成功进nacos的微服务提供者) service-url:nacos-user-service: http://nacos-payment-provider# 激活Sentinel对Feign的支持 feign:sentinel:enabled: true10 添加启动类 package com.yg.springcloud;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients;/*** Author suolong* Date 2022/6/22 11:38* Version 2.0*/ SpringBootApplication EnableDiscoveryClient EnableFeignClients public class OrderNacosMain84 {public static void main(String[] args) {SpringApplication.run(OrderNacosMain84.class, args);}}11 添加payment接口和实现类 package com.yg.springcloud.service;import com.yg.springcloud.entities.CommonResult; import com.yg.springcloud.entities.Payment; import com.yg.springcloud.service.impl.PaymentFallbackService; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable;/*** Author suolong* Date 2022/6/22 11:45* Version 2.0*/ FeignClient(value nacos-payment-provider, fallback PaymentFallbackService.class)//调用中关闭9003服务提供者 public interface PaymentService {GetMapping(value /paymentSQL/{id})public CommonResultPayment paymentSQL(PathVariable(id) Long id);}package com.yg.springcloud.service.impl;import com.yg.springcloud.entities.CommonResult; import com.yg.springcloud.entities.Payment; import com.yg.springcloud.service.PaymentService; import org.springframework.stereotype.Component;/*** Author suolong* Date 2022/6/22 11:45* Version 2.0*/ Component public class PaymentFallbackService implements PaymentService {Overridepublic CommonResultPayment paymentSQL(Long id){return new CommonResult(444,服务降级返回,没有该流水信息,new Payment(id, errorSerial......));}}12 添加配置类 package com.yg.springcloud.config;import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate;/*** Author suolong* Date 2022/6/22 11:39* Version 2.0*/Configuration public class ApplicationContextConfig {BeanLoadBalancedpublic RestTemplate getRestTemplate(){return new RestTemplate();}}13 添加controller package com.yg.springcloud.controller;import com.alibaba.csp.sentinel.annotation.SentinelResource; import com.yg.springcloud.entities.CommonResult; import com.yg.springcloud.entities.Payment; import com.yg.springcloud.service.PaymentService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate;import javax.annotation.Resource;/*** Author suolong* Date 2022/6/22 11:40* Version 2.0*/ RestController public class CircleBreakerController {public static final String SERVICE_URL http://nacos-payment-provider;Resourceprivate RestTemplate restTemplate;RequestMapping(/consumer/fallback/{id})SentinelResource(value fallback, fallback handlerFallback) //fallback负责业务异常public CommonResultPayment fallback(PathVariable Long id) {CommonResultPayment result restTemplate.getForObject(SERVICE_URL /paymentSQL/ id, CommonResult.class, id);if (id 4) {throw new IllegalArgumentException(IllegalArgumentException,非法参数异常....);} else if (result.getData() null) {throw new NullPointerException(NullPointerException,该ID没有对应记录,空指针异常);}return result;}public CommonResult handlerFallback(PathVariable Long id, Throwable e) {Payment payment new Payment(id, null);return new CommonResult(444, 兜底异常handlerFallback,exception内容 e.getMessage(), payment);}//OpenFeignResourceprivate PaymentService paymentService;GetMapping(value /consumer/openfeign/{id})public CommonResultPayment paymentSQL(PathVariable(id) Long id) {if (id 4) {throw new RuntimeException(没有该id);}return paymentService.paymentSQL(id);}}14 只有fallback配置说明 15 只配置blockHandler说明 16 fallback和blockHandler都配置 若 blockHandler 和 fallback 都进行了配置则被限流降级而抛出 BlockException 时只会进入 blockHandler 处理逻辑 17 忽略属性 18 熔断框架对比 持久化 1 更改cloudalibaba-sentinel-service8401的pom ?xml version1.0 encodingUTF-8? 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.xsdparentartifactIdspringcloud2022/artifactIdgroupIdcom.yg/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdcloudalibaba-sentinel-service8401/artifactIddependencies!--SpringCloud ailibaba sentinel-datasource-nacos --dependencygroupIdcom.alibaba.csp/groupIdartifactIdsentinel-datasource-nacos/artifactId/dependencydependency!-- 引入自己定义的api通用包可以使用Payment支付Entity --groupIdcom.yg/groupIdartifactIdcloud-api-commons/artifactIdversion${project.version}/version/dependency!--SpringCloud ailibaba nacos --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactId/dependency!--SpringCloud ailibaba sentinel-datasource-nacos 后续做持久化用到--dependencygroupIdcom.alibaba.csp/groupIdartifactIdsentinel-datasource-nacos/artifactId/dependency!--SpringCloud ailibaba sentinel --dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-sentinel/artifactId/dependency!--openfeign--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactId/dependency!-- SpringBoot整合Web组件actuator --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency!--日常通用jar包配置--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdscoperuntime/scopeoptionaltrue/optional/dependencydependencygroupIdcn.hutool/groupIdartifactIdhutool-all/artifactIdversion4.6.3/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependencies/project2 更改application server:port: 8401spring:application:name: cloudalibaba-sentinel-servicecloud:nacos:discovery:#Nacos服务注册中心地址server-addr: ${REGISTER_HOST:10.10.196.247}:${REGISTER_PORT:8848} #配置Nacos地址sentinel:transport:#配置Sentinel dashboard地址dashboard: localhost:8080#默认8719端口假如被占用会自动从8719开始依次1扫描,直至找到未被占用的端口port: 8719datasource:ds1:nacos:server-addr: ${REGISTER_HOST:10.10.196.247}:${REGISTER_PORT:8848}dataId: cloudalibaba-sentinel-servicegroupId: DEFAULT_GROUPdata-type: jsonrule-type: flowmanagement:endpoints:web:exposure:include: *3 在nacos上添加配置文件 [{resource: /rateLimit/byUrl,limitApp: default,grade: 1,count: 1,strategy: 0,controlBehavior: 0,clusterMode: false} ]resource资源名称 limitApp来源应用 grade阈值类型0表示线程数1表示QPS count单机阈值 strategy流控模式0表示直接1表示关联2表示链路 controlBehavior流控效果0表示快速失败1表示Warm Up2表示排队等待 clusterMode是否集群 4 启动8401后刷新sentinel发现业务规则有了 SpringCloud无介绍快使用Seata处理分布式事务二十五 SpringCloud无介绍快使用sentinel服务熔断功能二十四 SpringCloud无介绍快使用sentinel注解SentinelResource的基本使用二十三 SpringCloud无介绍快使用sentinel热点key限流与系统规则的基本使用二十二 SpringCloud无介绍快使用sentinel熔断降级和限流的基本使用二十一 SpringCloud无介绍快使用Nacos集群和Nginx代理二十 SpringCloud无介绍快使用nacos配置中心的基本使用十九 SpringCloud无介绍快使用nacos注册中心的基本使用十八 SpringCloud无介绍快使用gateway通过微服务名实现动态路由十七 SpringCloud无介绍快使用gateway的基本使用十六 SpringCloud无介绍快使用Ribbon负载均衡工具与OpenFeign的使用十五 SpringCloud无介绍快使用使用Zookeeper替换Eureka服务注册与发现十四 SpringCloud无介绍快使用服务发现Discovery和Eureka自我保护十三 SpringCloud无介绍快使用集群cloud-provider-payment8002搭建十二 SpringCloud无介绍快使用集群Eureka服务注册中心cloud-eureka-server7002搭建十一 SpringCloud无介绍快使用单机Eureka服务注册中心cloud-eureka-server7001搭建十 SpringCloud无介绍快使用新建cloud-api-commons公共模块module九 SpringCloud无介绍快使用新建子module消费者订单模块八 SpringCloud无介绍快使用热部署devtools配置七 SpringCloud无介绍快使用子module提供者支付微服务业务开发六 SpringCloud无介绍快使用新建子module提供者支付微服务yml整合和新建启动类五 SpringCloud无介绍快使用新建子module提供者支付微服务pom整合四 SpringCloud无介绍快使用springcloud父工程pom文件整理三 SpringCloud无介绍快使用IDEA新建springcloud父工程二 SpringCloud无介绍快使用与Spingboot之间的兼容版本选择一 作为程序员第 191 篇文章每次写一句歌词记录一下看看人生有几首歌的时间wahahaha ... Lyric 换个乐器就像换个兵器 © 著作权归作者所有,转载或内容合作请联系作者 喜欢的朋友记得点赞、收藏、关注哦
http://www.w-s-a.com/news/751314/

相关文章:

  • 个人做电影网站服务器放国外安全吗建设通app
  • 西安公司网站开发快站官网平台
  • 北京网站设计公司哪个好网站开发属于哪个部门
  • 现在海外做的比较好一点的网站网站报价书
  • 做整站优化漳州建网站
  • jsp网站建设期末作业搜索引擎优化的定义是什么
  • 网站建设一级页面二级页面WordPress托管如果使用插件
  • 网站导航栏设计代码织梦做泰文网站
  • 网站建设的定位是什么南通网站定制费用
  • 怎么seo网站推广能免费观看所有电视剧的app
  • 大学网站建设做网站的用什么软件呢
  • 网站建设建设公司哪家好seo网站优化推广
  • 网站服务器组建网站案例上海
  • 盘锦949公社最新招聘优化大师免费版
  • 国外有哪些网站是做弱电的中国国家培训网正规吗
  • 30分钟网站建设教程视频全屋整装120平米的多少钱
  • 生成链接的网站aso优化平台
  • 策划网站建设方案电商扶贫网站建设
  • 网站策划建设方法企业网站建设问题研究
  • 昆明专业网站建设的公司帮别人制作wordpress赚钱吗
  • 高校校园网站建设天水市建设局网站公告
  • 北京网站建设需要花多少钱企业建设网站的目的是
  • 网站模板 免费百度seo优化招聘
  • 过年做那些网站能致富怎样免费建立自己网站
  • 网站去哪里备案长沙网络推广
  • 企业网站规划书vue适合什么样的网站开发
  • 个人网站备案名字网站设计的提案
  • 网站自己做还是找人做常州钟楼区邹区建设局网站
  • 网站文件上传wordpress修改asp做微网站
  • 妇女之家网站建设方案英语不行如何编程做网站