nacos-discovery-test
org.springframework.boot
spring-boot-starter-parent
${spring.boot.version}
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
org.springframework.cloud
spring-cloud-dependencies
${spring.cloud.version}
pom
import
com.alibaba.cloud
spring-cloud-alibaba-dependencies
${spring.cloud.alibaba.version}
pom
import
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-actuator
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
org.springframework.boot
spring-boot-maven-plugin
application.properties
配置。一些关于 Nacos 基本的配置也必须在 application.properties(也可以是application.yaml)配置,
如下所示: application.yml
server:
port: 8081
spring:
application:
name: nacos-producer
cloud:
nacos:
discovery:
server-addr: 10.7.11.13:8848
如果不想使用 Nacos 作为您的服务注册与发现,可以将
spring.cloud.nacos.discovery.enabled
设置为false
。
@SpringBootApplication
@EnableDiscoveryClient
public class NacosProviderDemoAppli