mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
update example readme nacos port to 8848
This commit is contained in:
parent
e4d9f98313
commit
b4ec84c078
@ -21,7 +21,7 @@
|
||||
|
||||
2. 在应用的 /src/main/resources/bootstrap.properties 配置文件中配置 Nacos Config 地址
|
||||
|
||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8080
|
||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
||||
|
||||
3. 完成上述两步后,应用会从 Nacos Config 中获取相应的配置,并添加在 Spring Environment 的 PropertySources 中。这里我们使用 @Value 注解来将对应的配置注入到 SampleController 的 userName 和 age 字段,并添加 @RefreshScope 打开动态刷新功能
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
|
||||
3. 在命令行执行如下命令,向 Nacos Server 中添加一条配置。
|
||||
|
||||
curl -X POST "http://127.0.0.1:8080/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=17"
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=17"
|
||||
|
||||
**注:你也可以使用其他方式添加,遵循 HTTP API 规范即可,若您使用的 Nacos 版本自带控制台,建议直接使用控制台进行配置**
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
#### 验证动态刷新
|
||||
1. 执行如下命令,修改 Nacos Server 端的配置数据
|
||||
|
||||
curl -X POST "http://127.0.0.1:8080/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=18"
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=18"
|
||||
|
||||
2. 在浏览器地址栏输入 `http://127.0.0.1:18084/user`,并点击调转,可以看到应用从 Nacos Server 中获取了最新的数据,age 变成了 18。
|
||||
|
||||
|
@ -21,7 +21,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
|
||||
|
||||
2. Add Nacos server address configurations to file /src/main/resources/bootstrap.properties
|
||||
|
||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8080
|
||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
||||
|
||||
3. After completing the above two steps, the application will get the externalized configuration from Nacos Server and put it in the Spring Environment's PropertySources.We use the @Value annotation to inject the corresponding configuration into the userName and age fields of the SampleController, and add @RefreshScope to turn on dynamic refresh .
|
||||
@RefreshScope
|
||||
@ -50,7 +50,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
|
||||
|
||||
3. Execute the following command to add a configuration to Nacos Server.
|
||||
|
||||
curl -X POST "http://127.0.0.1:8080/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=17"
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=17"
|
||||
|
||||
**Note: You can also add it in other ways. If you are using the Nacos version with its own console, it is recommended to configure it directly using the console.**
|
||||
|
||||
@ -89,7 +89,7 @@ Enter `http://127.0.0.1:18084/user` in the browser address bar and click Go to,
|
||||
#### Dynamic Refresh
|
||||
1. Run the following command to modify the configuration data on the Nacos Server side.
|
||||
|
||||
curl -X POST "http://127.0.0.1:8080/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=18"
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos-config-example.properties&group=DEFAULT_GROUP&content=user.id=1%0Auser.name=james%0Auser.age=18"
|
||||
|
||||
2. Enter `http://127.0.0.1:18084/user` in the browser address bar and click Go to,
|
||||
We can see that the app got the latest data from Nacos Server and the age becomes 18.
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
2. 在应用的 /src/main/resources/application.properties 配置文件中配置 Nacos Server 地址
|
||||
|
||||
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080
|
||||
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
|
||||
|
||||
3. 使用 @EnableDiscoveryClient 注解开启服务注册与发现功能
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
### 验证
|
||||
|
||||
#### 查询服务
|
||||
在浏览器输入此地址 `http://127.0.0.1:8080/nacos/v1/ns/instances?serviceName=service-provider`,并点击跳转,可以看到服务节点已经成功注册到 Nacos Server。
|
||||
在浏览器输入此地址 `http://127.0.0.1:8848/nacos/v1/ns/instances?serviceName=service-provider`,并点击跳转,可以看到服务节点已经成功注册到 Nacos Server。
|
||||
|
||||

|
||||
|
||||
|
@ -20,7 +20,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
|
||||
|
||||
2. Add Nacos server address configurations to file /src/main/resources/application.properties.
|
||||
|
||||
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080
|
||||
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
|
||||
|
||||
3. Use the @EnableDiscoveryClient annotation to turn on service registration and discovery.
|
||||
|
||||
@ -72,7 +72,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
|
||||
|
||||
#### Query Service
|
||||
|
||||
Enter `http://127.0.0.1:8080/nacos/v1/ns/instances?serviceName=service-provider` in the browser address bar and click Go to, we can see that the service node has been successfully registered to Nacos Server.
|
||||
Enter `http://127.0.0.1:8848/nacos/v1/ns/instances?serviceName=service-provider` in the browser address bar and click Go to, we can see that the service node has been successfully registered to Nacos Server.
|
||||
|
||||

|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user