电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術(shù)文章
文章詳情頁

淺談springcloud常用依賴和配置

瀏覽:5日期:2023-07-13 08:37:15
spring cloud常用依賴和配置整理

淺談springcloud常用依賴和配置

常用依賴

// pom.xml<?xml version='1.0' encoding='UTF-8'?><project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd'> <modelVersion>4.0.0</modelVersion> <groupId>com.roit</groupId> <artifactId>config</artifactId> <version>1.0.0</version> <!-- 微服務(wù)的包 --> <packaging>pom</packaging> <!-- spring-boot 父工程 --> <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.3.RELEASE</version><relativePath/> </parent> <properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version> </properties> <dependencyManagement><dependencies> <!-- spring-cloud 依賴 https://spring.io/projects/spring-cloud --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Hoxton.SR7</version><type>pom</type><scope>import</scope> </dependency> <!-- 啟動類長運行配置 @SpringBootApplication --> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- eureka 服務(wù)端 @EnableConfigServer http://localhost:8761 --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> <!-- eureka 客戶端 @EnableEurekaClient --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-netflix-eureka-client</artifactId> </dependency> <!-- consul 注冊 http://localhost:8500/ui/dc1/services --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId> </dependency> <!-- nacos 注冊 http://localhost:8848/nacos --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <dependency><groupId>org.springframework.cloud</groupId><artifactId>nacos-client</artifactId> </dependency> <!-- feign 聲明式服務(wù)調(diào)用 替代 RestTemplate @EnableFeignClients --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <!-- hystrix 熔斷器,服務(wù)降級 @EnableCircuitBreaker --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency> <!-- hystrix 圖形化監(jiān)控,只能監(jiān)控一個服務(wù) @EnableHystrixDashboard http://localhost:8769/hystrix --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <!-- turbine 聚合監(jiān)控 @EnableTurbine http://localhost:8769/turbine.stream --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency> <!-- spring-boot 提供的監(jiān)控 --> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 網(wǎng)關(guān) --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId> </dependency> <!-- git 配置類服務(wù)端 @EnableConfigServer http://localhost/8888/master/config-dev.yml --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId> </dependency> <!-- git 配置類客戶端 --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId> </dependency> <!-- bus-rabbitmq 消息總線,做 config 自動刷新 --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency> <!-- stream-rabbitmq 發(fā)送消息 --> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-stream-rabbit</artifactId> </dependency> <!-- sleuth + zipkin 服務(wù)鏈路追蹤。需要 zipkin 的 jar包,圖形化查看地址 http://localhost:9411--> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zipkin</artifactId> </dependency></dependencies> </dependencyManagement></project>

配置

// application.yml# 設(shè)置端口server: port: 8000# 服務(wù)名spring: application: name: eureka# eureka 配置eureka: instance: hostname: localhost client: service-url: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka # 是否需要將自己的路徑注冊到 eureka 服務(wù)端 register-with-eureka: true # 是否需要從 eureka 服務(wù)端抓取路徑 fetch-registry: true# consulspring: cloud: consul: host: localhost port: 8500 discovery:# 注冊到 consul 的服務(wù)名service-name: ${spring.application.name}# 監(jiān)控界面顯示 ipprefer-ip-address: true# nacosspring: cloud: nacos: discovery:# 服務(wù)端地址server-addr: 127.0.0.1:8848# ribben 負載均衡策略provider: ribbon: NFloadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule# feign 超時配置, 集成了 ribbonribbon: # 連接超時時間 默認(rèn) 1000ms ConnectTimeout: 1000 # 邏輯處理超時時間 默認(rèn) 1000ms ReadTimeout: 3000#feign 集成了 hystrix,開啟 hystrixfeign: hystrix: enabled: true# feign 設(shè)置日志級別,只支持 debug, 請求響應(yīng)的相關(guān)數(shù)據(jù)logging: level: com.roit.controller: debug# turbine 聚合監(jiān)控turbine: combine-host-port: true # 配置監(jiān)控的服務(wù)名 app-config: provider,consumer cluster-name-expression: '’default’' aggregator: cluster-config: default #instanceUrlSuffix: /actuator/hystrix.stream# gateway 網(wǎng)關(guān)spring: cloud: gateway: routes: - id: provider# provider 的靜態(tài)訪問路徑# uri: http://localhost:8001/# 動態(tài)uri: lb://provider# 匹配規(guī)則predicates:- Path=/goods/**# 局部過濾器filters: - AddRequestParameter=username,zs discovery:locator: # 請求路徑加上微服務(wù)名稱,http://localhost/provider/goods/ 或 http://localhost/goods/ 都行 enabled: true # 默認(rèn)名稱大寫,改為允許小寫 lower-case-service-id: true# config 服務(wù)端spring: cloud: config: server:# 文件的倉庫地址git: uri: https://gitee.com/config.git # username: zs # password: 123 # 文件所在分支 label: master# config 客戶端,bootstrap.ymlspring: cloud: config: # http://localhost:8888/master/config-dev.yml # config 服務(wù)端地址 # uri: http://localhost:8888 name: config profile: dev,redis label: master # 動態(tài)配置 config 服務(wù)端地址,先將config 服務(wù)端注冊到 eureka discovery:enabled: true# config 服務(wù)端的名字,大寫service-id: config-server# config 客戶端 單服務(wù)自動刷新# 1. 加依賴 actuator# 2. 獲取數(shù)據(jù)的 controller 上加@RefreshScope# 3. curl -X POST http://localhost:8001/actuator/refreshmanagement: endpoints: web: exposure:# * 暴露所有;refresh 暴露自動刷新,/actuator/refresh。include: ’*’# bus 自動刷新,先給 config-server 發(fā)消息,再由 server 去通知所有的 config-client# bus-amqp 內(nèi)部使用 rabbitmq 發(fā)消息# config-server 需暴露 bus-refresh 和 配置 rabbitmq# curl -X POST http://localhost:8888/actuator/bus-refreshinclude: ’bus-refresh’# config-client 需配置 rabbitmq 和 在獲取數(shù)據(jù)的 controller 上加 @RefreshScopespring: rabbitmq: host: localhost port: 5672 username: guest password: guest virtual-host: /# stream-rabbitspring: cloud: stream: binders:# 定義綁定器名稱mybinder: type: rabbit # 指定 mq 的環(huán)境 environment: spring: rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: / bindings:# 生產(chǎn)者 @EnableBinding(Source.class)output:# 消費者 @EnableBinding(Sink.class), @StreamListener(Sink.INPUT)# input: binder: mybinder # 綁定的交換機名稱 destination: myexchange# sleuth + zipkinspring: zipkin: # zipkin 服務(wù)端路徑 base-url: http://lacalhost:9411/ sleuth: sampler: # 數(shù)據(jù)采集率 默認(rèn)0.1 probability: 0.1

到此這篇關(guān)于淺談spring cloud常用依賴和配置的文章就介紹到這了,更多相關(guān)spring cloud依賴和配置內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 翰香原枣子坊加盟费多少钱-正宗枣核糕配方培训利润高飘香 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 百度网站优化,关键词排名,SEO优化-搜索引擎营销推广 | 能耗监测系统-节能监测系统-能源管理系统-三水智能化 | 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | 发光字|标识设计|标牌制作|精神堡垒 - 江苏苏通广告有限公司 | 贝朗斯动力商城(BRCPOWER.COM) - 买叉车蓄电池上贝朗斯商城,价格更超值,品质有保障! | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 水质监测站_水质在线分析仪_水质自动监测系统_多参数水质在线监测仪_水质传感器-山东万象环境科技有限公司 | 全自动不干胶贴标机_套标机-上海今昂贴标机生产厂家 | 小型单室真空包装机,食品单室真空包装机-百科 | 山东聚盛新型材料有限公司-纳米防腐隔热彩铝板和纳米防腐隔热板以及钛锡板、PVDF氟膜板供应商 | 小型高低温循环试验箱-可程式高低温湿热交变试验箱-东莞市拓德环境测试设备有限公司 | 耐高温硅酸铝板-硅酸铝棉保温施工|亿欧建设工程 | 合肥防火门窗/隔断_合肥防火卷帘门厂家_安徽耐火窗_良万消防设备有限公司 | 英超直播_英超免费在线高清直播_英超视频在线观看无插件-24直播网 | 质检报告_CE认证_FCC认证_SRRC认证_PSE认证_第三方检测机构-深圳市环测威检测技术有限公司 | 上海律师咨询_上海法律在线咨询免费_找对口律师上策法网-策法网 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 灌木树苗-绿化苗木-常绿乔木-价格/批发/基地 - 四川成都途美园林 | 吊篮式|移动式冷热冲击试验箱-二槽冷热冲击试验箱-广东科宝 | 切铝机-数控切割机-型材切割机-铝型材切割机-【昆山邓氏精密机械有限公司】 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 扬子叉车厂家_升降平台_电动搬运车|堆高车-扬子仓储叉车官网 | 杭州营业执照代办-公司变更价格-许可证办理流程_杭州福道财务管理咨询有限公司 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 集装箱箱号识别_自重载重图像识别_铁路车号自动识别_OCR图像识别 | 除尘器布袋骨架,除尘器滤袋,除尘器骨架,电磁脉冲阀膜片,卸灰阀,螺旋输送机-泊头市天润环保机械设备有限公司 | 苏州防水公司_厂房屋面外墙防水_地下室卫生间防水堵漏-苏州伊诺尔防水工程有限公司 | 驾驶人在线_专业学车门户网站 | 聚丙烯酰胺_厂家_价格-河南唐达净水材料有限公司 | 工业铝型材生产厂家_铝合金型材配件批发精加工定制厂商 - 上海岐易铝业 | 冷藏车-东风吸污车-纯电动环卫车-污水净化车-应急特勤保障车-程力专汽厂家-程力专用汽车股份有限公司销售二十一分公司 | 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 宁波普瑞思邻苯二甲酸盐检测仪,ROHS2.0检测设备,ROHS2.0测试仪厂家 | 酒吧霸屏软件_酒吧霸屏系统,酒吧微上墙,夜场霸屏软件,酒吧点歌软件,酒吧互动游戏,酒吧大屏幕软件系统下载 | 厌氧反应器,IC厌氧反应器,厌氧三相分离器-山东创博环保科技有限公司 | 中药二氧化硫测定仪,食品二氧化硫测定仪|俊腾百科 | 中国在职研究生招生信息网 | 粘度计维修,在线粘度计,二手博勒飞粘度计维修|收购-天津市祥睿科技有限公司 |