Nacos是一个开源的分布式系统服务和基础设施解决方案,用于实现动态服务发现、配置管理和服务治理。它可以帮助开发人员和运维团队更好地管理微服务架构中的服务实例、配置信息和服务调用。
Nacos提供了服务注册与发现、动态配置管理、服务路由和负载均衡等功能,可以帮助企业构建和管理基于微服务架构的应用程序。它支持多种环境和语言,包括Java、Go、Python和Node.js等,可以灵活地集成到各种不同的应用程序中。
Nacos的特点包括高可用性、可扩展性、易用性和丰富的功能,使其成为构建和管理分布式系统的理想选择。作为一个开源项目,Nacos还拥有一个活跃的社区和丰富的文档资源,可以帮助用户更好地理解和使用该系统。
| 插件 | 版本 |
| jdk | 21 |
| springboot | 3.0.11 |
| springcloud | 2022.0.4 |
| springcloudalibaba | 2022.0.0.0 |
| nacos | 2.2.3(稳定版) |
- "1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0modelVersion>
- <parent>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-parentartifactId>
- <version>3.0.11version>
- <relativePath/>
- parent>
- <groupId>com.examplegroupId>
- <artifactId>platformartifactId>
- <version>0.0.1-SNAPSHOTversion>
- <name>platformname>
- <description>platformdescription>
- <properties>
- <java.version>21java.version>
- <spring-cloud.version>2022.0.0spring-cloud.version>
- <spring-cloud-alibaba.version>2022.0.0.0spring-cloud-alibaba.version>
- properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-webartifactId>
- dependency>
- <dependency>
- <groupId>org.mybatis.spring.bootgroupId>
- <artifactId>mybatis-spring-boot-starterartifactId>
- <version>3.0.2version>
- dependency>
- <dependency>
- <groupId>com.baomidougroupId>
- <artifactId>mybatis-plus-boot-starterartifactId>
- <version>3.5.3.2version>
- dependency>
- <dependency>
- <groupId>com.mysqlgroupId>
- <artifactId>mysql-connector-jartifactId>
- <scope>runtimescope>
- dependency>
- <dependency>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-starter-testartifactId>
- <scope>testscope>
- dependency>
- <dependency>
- <groupId>org.mybatis.spring.bootgroupId>
- <artifactId>mybatis-spring-boot-starter-testartifactId>
- <version>3.0.2version>
- <scope>testscope>
- dependency>
- <dependency>
- <groupId>org.projectlombokgroupId>
- <artifactId>lombokartifactId>
- <version>edge-SNAPSHOTversion>
- dependency>
- <dependency>
- <groupId>javax.validationgroupId>
- <artifactId>validation-apiartifactId>
- <version>2.0.1.Finalversion>
- dependency>
- <dependency>
- <groupId>org.apache.commonsgroupId>
- <artifactId>commons-lang3artifactId>
- dependency>
- <dependency>
- <groupId>com.alibaba.cloudgroupId>
- <artifactId>spring-cloud-starter-alibaba-nacos-configartifactId>
- dependency>
- <dependency>
- <groupId>com.alibaba.cloudgroupId>
- <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
- dependency>
- <dependency>
- <groupId>org.springframework.cloudgroupId>
- <artifactId>spring-cloud-starter-openfeignartifactId>
- dependency>
- <dependency>
- <groupId>org.springframework.cloudgroupId>
- <artifactId>spring-cloud-starter-bootstrapartifactId>
- dependency>
- <dependency>
- <groupId>com.alibabagroupId>
- <artifactId>fastjsonartifactId>
- <version>2.0.41version>
- dependency>
- <dependency>
- <groupId>com.auth0groupId>
- <artifactId>java-jwtartifactId>
- <version>4.4.0version>
- dependency>
- <dependency>
- <groupId>org.springframework.cloudgroupId>
- <artifactId>spring-cloud-loadbalancerartifactId>
- dependency>
- dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloudgroupId>
- <artifactId>spring-cloud-dependenciesartifactId>
- <version>${spring-cloud.version}version>
- <type>pomtype>
- <scope>importscope>
- dependency>
- <dependency>
- <groupId>com.alibaba.cloudgroupId>
- <artifactId>spring-cloud-alibaba-dependenciesartifactId>
- <version>${spring-cloud-alibaba.version}version>
- <type>pomtype>
- <scope>importscope>
- dependency>
- dependencies>
- dependencyManagement>
-
- <repositories>
- <repository>
- <id>projectlombok.orgid>
- <url>https://projectlombok.org/edge-releasesurl>
- repository>
- repositories>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-maven-pluginartifactId>
- plugin>
- plugins>
- build>
-
- project>
- spring:
- application:
- name: platform
- cloud:
- nacos:
- server-addr: ip:port
- config:
- file-extension: yml
- group: DEFAULT_GROUP
- prefix: ${sping.application.name}
- @SpringBootApplication
- // 这里必须有
- @EnableFeignClients
- public class PlatformApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(PlatformApplication.class, args);
- }
-
- }
- @SpringBootApplication
- @EnableFeignClients
- @EnableCaching
- @EnableScheduling
- @EnableDiscoveryClient
- @RefreshScope
- public class PlatformApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(PlatformApplication.class, args);
- }
-
- }
