生成如下目录结构:
pom.xml
依赖
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.2.RELEASE
com.aqin
my-simulator
0.0.1-SNAPSHOT
my-simulator
my-simulator
1.8
org.springframework.cloud
spring-cloud-dependencies
Hoxton.SR9
pom
import
com.alibaba.cloud
spring-cloud-alibaba-dependencies
2.2.6.RELEASE
pom
import
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-web
org.springframework.cloud
spring-cloud-context
2.2.2.RELEASE
org.springframework.boot
spring-boot-starter-test
test
org.projectlombok
lombok
true
com.alibaba.cloud
spring-cloud-alibaba-nacos-config
2.2.0.RELEASE
org.springframework.boot
spring-boot-maven-plugin
org.projectlombok
lombok
application.properties
里配置端口号bootstrap.properties
配置Nacos信息打开命令行,进入到你电脑的Nacos的bin
目录下,我这里是:/Users/aqin1012/Java/nacos/bin
调用sh startup.sh -m standalone
启动单个Nacos
http://127.0.0.1:8848/nacos/
)(1) 新建配置文件:
(2) 填写配置参数:
此处使用Postman进行简单的本地测试
(1) 直接发送请求(localhost:8085/aqin/testNacosConfig/
)
(2) 修改Nacos的配置参数并发布
(3) 不重启服务,再次发送请求
嘿嘿搞定,撒花~~