报错原因是默认启动的是集群模式,这里我先改为单机模式。把cluster改为standalone
重启后成功
访问:http://localhost:8848/nacos/ 默认用户名和密码都是nacos
项目中集成
pom
<?xml version="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.0</modelVersion> <groupId>com.iflytek.pr.spart</groupId> <artifactId>pr-spart</artifactId> <version>1.0.0</version> <name>pr-spart</name> <!-- Spring Boot 启动父依赖 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.4.RELEASE</version> </parent> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>2.2.6.RELEASE</version> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>2.2.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> <version>3.1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <target>${java.version}</target> <source>${java.version}</source> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.6</version> <configuration> <jvmArguments>-Dfile-encoding=UTF-8</jvmArguments> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> </plugin> </plugins> </build> </project>View Code
bootstrap.yaml
spring: application: name: znbb-web-wwlu profiles: active: dev cloud: nacos: server-addr: ${spring.cloud.nacos.server-addr} #nacos服务地址 config: timeout: 3000 refresh-enabled: true #修改后自动加载 group: DEFAULT_GROUP #nacos配置文件所选择的group prefix: ${spring.application.name} file-extension: properties #读取nacos配置文件后缀View Code 标签:spring,boot,nacos,cloud,org,starter From: https://www.cnblogs.com/JYB2021/p/16796295.html