其他分享
首页 > 其他分享> > Nacos入门

Nacos入门

作者:互联网

1.在父项目中引入SpringCloudAlibaba依赖

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring.cloud-version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2.2.5.RELEASE</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

2.在服务提供项目中新增Nacos服务发现依赖及配置

<dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
spring:
  application:
    name: consumer
  cloud:
    nacos:
      server-addr: localhost:8848

即可将服务注册到Nacos注册中心。

nacos服务的调用方式与Eureka的调用方式相同,都使用RestTemplate调用,同样需要在RestTemplate 注入方法上添加负载均衡注解

nacos服务分级存储模型:1.服务 2.集群 3.实例

 

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back

标签:入门,spring,nacos,Nacos,alibaba,com,cloud
来源: https://www.cnblogs.com/myvoice/p/16606965.html