The starting point for microservices is service registration and discovery, and the Spring Cloud Alibaba series will use Nacos for service registration and discovery.

This section mainly uses nacOS-Server 1.4.1 for demonstration.

1 the service side

1.1 download nacos – server

Download.csdn.net/download/qq…

1.2 Starting the Service

Take the Mac as an example.

The nacos/bin directory is displayed.

Start command:

sh startup.sh -m standalone
Copy the code

1.3 Management Platform

Address: http://localhost:8848/nacos

The default account is nacos

The default password is nacos

1.4 Stopping Services

Take the Mac as an example.

The nacos/bin directory is displayed.

Start command:

sh shutdown.sh
Copy the code

1.5 Screen Shot

2 the client

2.1 depend on

<! -- NacOS service registration -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
Copy the code

2.2 Automatic Configuration

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE  file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this File to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the  License. */
package com.fengwenyi.demouserservicecore.config;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;

/ * * *@author <a href="mailto:[email protected]">theonefx</a>
 */
@EnableDiscoveryClient
@Configuration
public class NacosDiscoveryConfiguration {}Copy the code

2.3 configuration

spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.group=springcloud-alibaba-demo
Copy the code

2.4 Screen Shot

3 data

  • Nacos-server:github.com/alibaba/nac…
  • Springcloud-alibaba-demo:gitee.com/fengwenyi/s…