gateway配合nacos路由报错:Unable to find instance for XXX

gateway配合nacos 找不到服务的问题
nacos版本: 1.1.4
spring-boot版本: 2.5.2
spring-cloud版本: 2020.0.3
spring-cloud-alibaba版本: 2021.1

gateway网关pom.xml

<dependencies>
	
    <dependency>
        <groupId>org.springframework.cloudgroupId>
        <artifactId>spring-cloud-starter-gatewayartifactId>
    dependency>
    
    <dependency>
        <groupId>com.alibaba.cloudgroupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
    dependency>
dependencies>

api服务pom.xml

<dependencies>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
    
    <dependency>
        <groupId>com.alibaba.cloudgroupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
    dependency>
dependencies>

nacos:
gateway配合nacos路由报错:Unable to find instance for XXX_第1张图片
浏览器访问
gateway配合nacos路由报错:Unable to find instance for XXX_第2张图片
找了很多资料,终于找到说Spring Cloud2020移除了Ribbon,加入依赖后成功解决问题:


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-loadbalancerartifactId>
dependency>

资料:https://blog.csdn.net/qq_35136937/article/details/116798268

你可能感兴趣的:(随笔)