The following shows the other configurations of the starter of Nacos Discovery:

Configuration

Key

Default Value

Description

Server address

spring.cloud.nacos.discovery.server-addr

IP and port of the Nacos Server listener

Service name

spring.cloud.nacos.discovery.service

${spring.application.name}

Name the current service

Weight

spring.cloud.nacos.discovery.weight

1

Value range: 1 to 100. The bigger the value, the greater the weight

Network card name

spring.cloud.nacos.discovery.network-interface

If the IP address is not specified, the registered IP address is the IP address of the network card. If this is not specified either, the IP address of the first network card will be used by default.

Registered IP address

spring.cloud.nacos.discovery.ip

Highest priority

Registered port

spring.cloud.nacos.discovery.port

-1

Will be detected automatically by default. Do not need to be configured.

Namespace

spring.cloud.nacos.discovery.namespace

A typical scenario is to isolate the service registration for different environment, such as resource (configurations, services etc.) isolation between testing and production environment

AccessKey

spring.cloud.nacos.discovery.access-key

Alibaba Cloud account accesskey

SecretKey

spring.cloud.nacos.discovery.secret-key

Alibaba Cloud account secretkey

Metadata

spring.cloud.nacos.discovery.metadata

You can define some of the metadata for your services in the Map format

Log file name

spring.cloud.nacos.discovery.log-name

Cluster Name

spring.cloud.nacos.discovery.cluster-name

DEFAULT

Cluster name of Nacos

Endpoint

spring.cloud.nacos.discovery.endpoint

The domain name of a certain service in a specific region. You can retrieve the server address dynamically with this domain name

Integrate Ribbon or not

ribbon.nacos.enabled

true

Set to true in most cases

Enable Nacos Watch

spring.cloud.nacos.discovery.watch.enabled

true

set to false to close watch

group spring.cloud.nacos.discovery.group customize group

NacosDiscoveryProperties
@ConfigurationProperties("spring.cloud.nacos.discovery")
public class NacosDiscoveryProperties {

}

处理ip逻辑
@PostConstruct
public void init() throws SocketException {

	metadata.put(PreservedMetadataKeys.REGISTER_SOURCE, "SPRING_CLOUD");
	if (secure) {
		metadata.put("secure", "true");
	}

	serverAddr = Objects.toString(serverAddr, "");
	if (serverAddr.endsWith("/")) {
		serverAddr = serverAddr.substring(0, serverAddr.length() - 1);
	}
	endpoint = Objects.toString(endpoint, "");
	namespace = Objects.toString(namespace, "");
	logName = Objects.toString(logName, "");

	if (StringUtils.isEmpty(ip)) {
		// traversing network interfaces if didn't specify a interface
		if (StringUtils.isEmpty(networkInterface)) {
			ip = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
		}
		else {
			NetworkInterface netInterface = NetworkInterface
					.getByName(networkInterface);
			if (null == netInterface) {
				throw new IllegalArgumentException(
						"no such interface " + networkInterface);
			}

			Enumeration<InetAddress> inetAddress = netInterface.getInetAddresses();
			while (inetAddress.hasMoreElements()) {
				InetAddress currentAddress = inetAddress.nextElement();
				if (currentAddress instanceof Inet4Address
						&& !currentAddress.isLoopbackAddress()) {
					ip = currentAddress.getHostAddress();
					break;
				}
			}

			if (StringUtils.isEmpty(ip)) {
				throw new RuntimeException("cannot find available ip from"
						+ " network interface " + networkInterface);
			}

		}
	}

	this.overrideFromEnv(environment);
}