国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos

這篇具有很好參考價(jià)值的文章主要介紹了微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos,微服務(wù),微服務(wù),架構(gòu),云原生

認(rèn)識(shí)微服務(wù)

微服務(wù)架構(gòu)演變:

單體架構(gòu):所有功能集中在一個(gè)項(xiàng)目中開發(fā),打成一個(gè)包部署

分布式架構(gòu):就是各功能模塊的代碼不在同一個(gè)項(xiàng)目中寫了,到時(shí)候修改其中一個(gè)過能的代碼,對(duì)另一個(gè)功能完全沒有任何影響(如果在一個(gè)項(xiàng)目中,修改這個(gè)功能的代碼,就得將所有功能代碼給重新編譯)

服務(wù)治理

問題:
服務(wù)拆分力度
服務(wù)集群地址如何維護(hù)
服務(wù)之間如何實(shí)現(xiàn)遠(yuǎn)程 調(diào)用
服務(wù)健康狀態(tài)如何感知

微服務(wù)

良好架構(gòu)設(shè)計(jì)的分布式架構(gòu)方案,微服務(wù)架構(gòu)特征
單一職責(zé):功能單一
面向服務(wù):對(duì)外暴露接口(讓其他服務(wù)調(diào)用)
自治:團(tuán)隊(duì)獨(dú)立,技術(shù)獨(dú)立,數(shù)據(jù)獨(dú)立,部署獨(dú)立
隔離降級(jí):服務(wù)做好隔離,容器,降級(jí),避免出現(xiàn)級(jí)聯(lián)問題

維護(hù)服務(wù)節(jié)點(diǎn)信息 – 注冊(cè)中心
微服務(wù)配置的修改 – 配置中心
用戶訪問的微服務(wù) – 服務(wù)網(wǎng)關(guān)
微服務(wù)間調(diào)用報(bào)錯(cuò) – 服務(wù)保護(hù)

微服務(wù)入門案例

微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos,微服務(wù),微服務(wù),架構(gòu),云原生

服務(wù)拆分與遠(yuǎn)程調(diào)用

服務(wù)拆分

拆分原則

這里我總結(jié)了微服務(wù)拆分時(shí)的幾個(gè)原則:

  • 不同微服務(wù),不要重復(fù)開發(fā)相同業(yè)務(wù)
  • 微服務(wù)數(shù)據(jù)獨(dú)立,不要訪問其它微服務(wù)的數(shù)據(jù)庫
  • 微服務(wù)可以將自己的業(yè)務(wù)暴露為接口,供其它微服務(wù)調(diào)用

入門案例

  1. 創(chuàng)建父項(xiàng)目
  • 導(dǎo)入依賴:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.12.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.zjh</groupId>
    <artifactId>cloud-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>cloud-demo</name>
    <description>cloud-demo</description>

    <!--父工程-->
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <!--  springCloud  -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.SR10</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--  mysql驅(qū)動(dòng)  -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <scope>runtime</scope>
                <version>8.0.15</version>
            </dependency>

            <!-- mybatis -->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.5.5</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

注意:
這里的環(huán)境是jdk8(建議大家和我一樣)

  1. 創(chuàng)建子項(xiàng)目user-service
  • 導(dǎo)入依賴
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.zjh</groupId>
        <artifactId>cloud-demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>com.zjh</groupId>
    <artifactId>user-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>user-service</name>
    <description>user-service</description>
    <properties>
        <java.version>8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

  • 創(chuàng)建實(shí)體類,mapper,service,controller

微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos,微服務(wù),微服務(wù),架構(gòu),云原生

  • 添加mybatis-plus包掃描配置
@SpringBootApplication
@MapperScan("com.zjh.userservice.mapper")
public class UserServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
    }

}
  • yml配置設(shè)置
server:
  port: 8089
spring:
  application:
    name: userservice
  datasource:
    url: jdbc:mysql://localhost:3306/cloud?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
    username: root
    password: 888888
    driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true
  type-aliases-package: com.zjh.order.pojo
  1. 創(chuàng)建子項(xiàng)目order-service

和user-service一模一樣,唯一的區(qū)別是,需要再order-service中添加user-service的依賴

<dependency>
    <groupId>com.zjh</groupId>
    <artifactId>user-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

遠(yuǎn)程調(diào)度

遠(yuǎn)程調(diào)用就是在代碼中訪問到另一個(gè)項(xiàng)目的地址,這樣就可以通過url來使用對(duì)方的方法,從而得到對(duì)方的信息
我們這里order中查詢中的user屬性直接查詢時(shí)得不到的,需要通過訪問user的信息,通過user-service中的getById()來得到,所以我們遠(yuǎn)程調(diào)度user-service項(xiàng)目

步驟:

  1. 在OrderServiceApplication中將RestTemplate添加到bean
@SpringBootApplication
@MapperScan("com.hwadee.order.mapper")
public class OrderServiceApplication {

	public static void main(String[] args) {
		SpringApplication.run(OrderServiceApplication.class, args);
	}

	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
}
  1. 調(diào)用RestTemplate來實(shí)現(xiàn)遠(yuǎn)程調(diào)度
@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

     @Autowired
    private RestTemplate restTemplate;


    public Order queryOrderById(Long orderId) {
        // 1.查詢訂單
        Order order = orderMapper.findById(orderId);
        
        // 2.利用RestTemplate發(fā)起http請(qǐng)求,查詢用戶
        // 2.1.url路徑
        String url = "http://localhost:8081/user/" + order.getUserId();
        // 2.2.發(fā)送http請(qǐng)求,實(shí)現(xiàn)遠(yuǎn)程調(diào)用
        User user = restTemplate.getForObject(url, User.class);
        
        // 3.封裝user到Order
        order.setUser(user);
        
        // 4.返回
        return order;
    }
}

支持請(qǐng)求:get,post,

存在問題:

  • order-service在發(fā)起遠(yuǎn)程調(diào)用的時(shí)候,該如何得知user-service實(shí)例的ip地址和端口?
  • 有多個(gè)user-service實(shí)例地址,order-service調(diào)用時(shí)該如何選擇?
  • order-service如何得知某個(gè)user-service實(shí)例是否依然健康,是不是已經(jīng)宕機(jī)?

我們接下來就使用用戶中心來看一看這個(gè)問題

Eureka注冊(cè)中心

介紹

eureka工作流程
微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos,微服務(wù),微服務(wù),架構(gòu),云原生
調(diào)用者就是服務(wù)消費(fèi)者,被調(diào)用的對(duì)象就是服務(wù)提供者。注冊(cè)中心,就是我們將服務(wù)提供者的路徑給存到注冊(cè)中心中,當(dāng)服務(wù)消費(fèi)者每次調(diào)用對(duì)面的服務(wù),就通過注冊(cè)中心來訪問對(duì)面的服務(wù)

使用步驟

創(chuàng)建注冊(cè)中心項(xiàng)目

  1. 添加依賴spring-cloud-starter-netflix-eureka-server
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hwadee</groupId>
        <artifactId>cloud-demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>eureka-server</artifactId>

    <dependencies>
        <!--eureka服務(wù)端-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.2.10.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
  1. 編寫eureka啟動(dòng)類
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
  1. 編寫服務(wù)配置文件
server:
  port: 10086
spring:
  application:
    name: eureka-server
eureka:
  client:
    service-url:
      defaultZone: http://127.0.0.1:10086/eureka
  1. 啟動(dòng)服務(wù)

啟動(dòng)微服務(wù),然后在瀏覽器訪問:http://127.0.0.1:10086

注冊(cè)服務(wù)

  1. 在user-service的pom文件中,引入下面的eureka-client依賴:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>2.2.10.RELEASE</version>
</dependency>

  1. 修改服務(wù)配置文件,向eureka注冊(cè)服務(wù),并添加名字
server:
  port: 8081

spring:
  application: # 給服務(wù)起名字
    name: user-service
  datasource:
    url: jdbc:mysql://localhost:3306/hwadee?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver
    
# 向eureka注冊(cè)服務(wù)
eureka:
  client:
    service-url:
      defaultZone: http://127.0.0.1:10086/eureka

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true
  type-aliases-package: com.hadee.user.pojo

使用

  1. 在order-service的pom文件中,引入下面的eureka-client依賴:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>2.2.10.RELEASE</version>
</dependency>

  1. 修改服務(wù)配置文件,向eureka注冊(cè)服務(wù),并添加名字
  2. 添加@LoadBalanced注解
  • @LoadBalanced,進(jìn)行輪循(將同一個(gè)名字的服務(wù)進(jìn)行輪詢?cè)L問)
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
    return new RestTemplate();
}
  1. 使用
public Order queryOrderById(Long orderId) {
    // 1.查詢訂單
    Order order = orderMapper.findById(orderId);
    // 2.利用RestTemplate發(fā)起http請(qǐng)求,查詢用戶
    // 2.1.url路徑
    String url = "http://user-service/user/" + order.getUserId();
    // 2.2.發(fā)送http請(qǐng)求,實(shí)現(xiàn)遠(yuǎn)程調(diào)用
    User user = restTemplate.getForObject(url, User.class);
    // 3.封裝user到Order
    order.setUser(user);
    // 4.返回
    return order;
}

Ribuu負(fù)載均衡

Nacos注冊(cè)中心

nacos介紹和安裝

  1. 安裝
  2. 運(yùn)行

打開安裝的nacos文件夾,在bin文件上建立終端頁,輸入以下語句啟動(dòng)

sh startup.sh -m standalone
  1. 訪問

nacos注冊(cè)中心地址: http://127.0.0.1:8848/nacos/index.html#/login (賬號(hào)密碼都是nacos)
如果讀取不到,可以嘗試將nacos注冊(cè)中心中的內(nèi)容刪除,然后重新運(yùn)行項(xiàng)目

簡單使用

  1. 引入依賴
<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-alibaba-dependencies</artifactId>
  <version>2.2.5.RELEASE</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>
<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
  1. 添加配置(user和order的.xml都需要)
spring:
  cloud:
    nacos:
      server-addr: 127.0.0.1:8848

Nacos配置管理

將配置放到nacos中

springboot啟動(dòng)加載配置文件順序
bootstrap.yml
application.properties
application.yml

增加dev,創(chuàng)建開發(fā)環(huán)境

dev – namespace 開發(fā)環(huán)境
public – namespace 生產(chǎn)環(huán)境

遠(yuǎn)程調(diào)用OpenFeign

  1. 引入依賴
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
    <version>2.2.10.RELEASE</version>
</dependency>
  1. 添加注解@EnableFeignClients
@SpringBootApplication
@MapperScan("com.zjh.orderservice.mapper")
@EnableFeignClients
public class OrderServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderServiceApplication.class, args);
    }
}
  1. 編寫Feign的接口類
@FeignClient("user-service")
public interface UserClient {
    @GetMapping("/user/{id}")
    User findById(@PathVariable("id") Long id);
}
  1. 使用
public Order queryOrderById(Long orderId) {
    // 1.查詢訂單
    Order order = orderMapper.findById(orderId);
    
    // 2.設(shè)置用戶
    // 2.1 查詢用戶
    User user = userClient.findById(order.getUserId());
    // 2.2 設(shè)置user
    order.setUser(user);
    
    // 3.返回
    return order;
}

和使用mapper類似,就是調(diào)用接口的方法文章來源地址http://www.zghlxwxcb.cn/news/detail-802074.html

到了這里,關(guān)于微服務(wù)入門 | 項(xiàng)目分割 | 遠(yuǎn)程調(diào)度Feign | 用戶中心erueka 和 nacos的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Nacos配置管理、Feign遠(yuǎn)程調(diào)用、Gateway服務(wù)網(wǎng)關(guān)

    Nacos配置管理、Feign遠(yuǎn)程調(diào)用、Gateway服務(wù)網(wǎng)關(guān)

    1.在Nacos中添加配置 Data Id = 服務(wù)名稱-環(huán)境名稱.yaml eg: userservice-dev.yaml 2.引入nacos-config依賴 在user-service服務(wù)中,引入nacos-config的客戶端依賴 3.添加 bootstrap.yaml ,我們這里以顯示一個(gè)日期時(shí)間為例 在user-service中添加一個(gè)bootstrap.yaml文件 4.編寫controller 方式一 給 @Value 注入的變量

    2024年02月12日
    瀏覽(22)
  • 微服務(wù)技術(shù)棧-Nacos配置管理和Feign遠(yuǎn)程調(diào)用

    微服務(wù)技術(shù)棧-Nacos配置管理和Feign遠(yuǎn)程調(diào)用

    在上篇文章中介紹了微服務(wù)技術(shù)棧中Nacos這個(gè)組件的概念,Nacos除了可以做注冊(cè)中心,同樣可以做配置管理來使用。同時(shí)我們將學(xué)習(xí)一種新的遠(yuǎn)程調(diào)用方式Feign,它可以幫助我們優(yōu)雅的實(shí)現(xiàn)http請(qǐng)求的發(fā)送。 Nacos除了可以做注冊(cè)中心,同樣可以做配置管理來使用。每個(gè)微服務(wù)可以

    2024年02月02日
    瀏覽(21)
  • 39.SpringCloud—配置管理nacos、遠(yuǎn)程調(diào)用Feign、服務(wù)網(wǎng)關(guān)Gateway

    39.SpringCloud—配置管理nacos、遠(yuǎn)程調(diào)用Feign、服務(wù)網(wǎng)關(guān)Gateway

    目錄 一、SpringCloud。 (1)Nacos配置管理。 (1.1)nacos中添加配置文件、微服務(wù)引入依賴,并配置bootstrap.yml文件。 (1.2)獲取配置文件信息,實(shí)現(xiàn)熱更新。 (1.3)多環(huán)境配置共享。 (1.4)多服務(wù)共享配置。 (2)http客戶端Feign。 (2.1)RestTemplate方式調(diào)用存在的問題。 (2.2)

    2024年02月10日
    瀏覽(97)
  • SpringCloud實(shí)用篇2——Nacos配置管理 Feign遠(yuǎn)程調(diào)用 Gateway服務(wù)網(wǎng)關(guān)

    SpringCloud實(shí)用篇2——Nacos配置管理 Feign遠(yuǎn)程調(diào)用 Gateway服務(wù)網(wǎng)關(guān)

    Nacos除了可以做注冊(cè)中心,同樣可以做配置管理來使用。 當(dāng)微服務(wù)部署的實(shí)例越來越多,達(dá)到數(shù)十、數(shù)百時(shí),逐個(gè)修改微服務(wù)配置就會(huì)讓人抓狂,而且很容易出錯(cuò)。我們需要一種統(tǒng)一配置管理方案,可以集中管理所有實(shí)例的配置。 Nacos一方面可以將配置集中管理,另一方可以

    2024年02月13日
    瀏覽(87)
  • 微服務(wù) feign遠(yuǎn)程調(diào)用時(shí) 顯示服務(wù)不可用 timed-out and no fallback

    目錄 第一種:?failed and no fallback available? 1 服務(wù)掛掉了 2 服務(wù)沒有開啟 3 注冊(cè)中心沒注冊(cè)進(jìn)去 ?- ps: 直接調(diào)用的接口 通過網(wǎng)關(guān)轉(zhuǎn)發(fā)失敗 會(huì)報(bào)503 4 高并發(fā)下的服務(wù)熔斷了 第二種:?timed-out and no fallback ?2.1 業(yè)務(wù)場景:? A服務(wù)一切正常 但是B服務(wù)顯示timeout 2.2? 改進(jìn)三種參數(shù) feign?

    2024年02月04日
    瀏覽(17)
  • 【學(xué)習(xí)日記2023.6.12】之nacos配置管理_Feign遠(yuǎn)程調(diào)用_Gateway服務(wù)網(wǎng)關(guān)

    【學(xué)習(xí)日記2023.6.12】之nacos配置管理_Feign遠(yuǎn)程調(diào)用_Gateway服務(wù)網(wǎng)關(guān)

    Nacos除了可以做注冊(cè)中心,同樣可以做配置管理來使用。 6.1 統(tǒng)一配置管理 當(dāng)微服務(wù)部署的實(shí)例越來越多,達(dá)到數(shù)十、數(shù)百時(shí),逐個(gè)修改微服務(wù)配置就會(huì)讓人抓狂,而且很容易出錯(cuò)。需要一種統(tǒng)一配置管理方案,可以集中管理所有實(shí)例的配置。 Nacos一方面可以將配置集中管理

    2024年02月09日
    瀏覽(15)
  • 微服務(wù)Day3——Nacos配置管理\Feign遠(yuǎn)程調(diào)用\Gateway網(wǎng)關(guān)

    微服務(wù)Day3——Nacos配置管理\Feign遠(yuǎn)程調(diào)用\Gateway網(wǎng)關(guān)

    當(dāng)微服務(wù)部署的實(shí)例越來越多,達(dá)到數(shù)十、數(shù)百時(shí),逐個(gè)修改微服務(wù)配置就會(huì)讓人抓狂,而且很容易出錯(cuò)。我們需要一種統(tǒng)一配置管理方案,可以集中管理所有實(shí)例的配置。 Nacos一方面可以將配置集中管理,另一方可以在配置變更時(shí),及時(shí)通知微服務(wù),實(shí)現(xiàn)配置的熱更新。

    2024年02月16日
    瀏覽(18)
  • Spring Cloud Day2 Nacos配置管理、Feign遠(yuǎn)程調(diào)用與Gateway服務(wù)網(wǎng)關(guān)

    Spring Cloud Day2 Nacos配置管理、Feign遠(yuǎn)程調(diào)用與Gateway服務(wù)網(wǎng)關(guān)

    Nacos除了可以做注冊(cè)中心,同樣可以做配置管理來使用。 當(dāng)微服務(wù)部署的實(shí)例越來越多,達(dá)到數(shù)十、數(shù)百時(shí),逐個(gè)修改微服務(wù)配置就會(huì)讓人抓狂,而且很容易出錯(cuò)。我們需要一種統(tǒng)一配置管理方案,可以集中管理所有實(shí)例的配置。 Nacos一方面可以將配置集中管理,另一方可以

    2024年02月10日
    瀏覽(21)
  • 微服務(wù) feign遠(yuǎn)程調(diào)用yml配置,并解決顯示服務(wù)不可用 timed-out and no fallback

    目錄 第一種:?failed and no fallback available? 1 服務(wù)掛掉了 2 服務(wù)沒有開啟 3 注冊(cè)中心沒注冊(cè)進(jìn)去 ?- ps: 直接調(diào)用的接口 通過網(wǎng)關(guān)轉(zhuǎn)發(fā)失敗 會(huì)報(bào)503 4 高并發(fā)下的服務(wù)熔斷了 第二種:?timed-out and no fallback ?2.1 業(yè)務(wù)場景:? A服務(wù)一切正常 但是B服務(wù)顯示timeout 2.2? 改進(jìn)三種參數(shù) feign?

    2024年02月12日
    瀏覽(16)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包