Nacos
简介
一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。 Reference
功能
- 动态服务配置
- 服务发现和管理
- 动态 DNS 服务
快速入门
通过 Docker 启动 Nacos
docker pull nacos/nacos-server
docker run --name nacos -d -p 8848:8848 -e MODE=standalone nacos/nacos-server
登录页面
http://192.168.31.201:8848/nacos/#/login
用户名密码为 nacos
Provider 端
依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<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>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
bootstrap.properties
spring.application.name=waiter-service
application.properties
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
info.app.author=DigitalSonic
info.app.encoding=@project.build.sourceEncoding@
server.port=0
spring.cloud.nacos.discovery.server-addr=192.168.31.201:8848
Customer 端
依赖(参考Provider)
bootstrap.properties
spring.application.name=customer-service
application.properties
server.port=0
management.endpoint.health.show-details=always
spring.cloud.nacos.discovery.server-addr=192.168.31.201:8848