mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 13:57:29 +08:00
增加 spring cloud alibaba nacos 配置中心
This commit is contained in:
@@ -17,21 +17,22 @@ public class DemoController {
|
||||
@Autowired
|
||||
private OrderProperties orderProperties;
|
||||
|
||||
// 测试 @ConfigurationProperties 注解的配置属性类
|
||||
/**
|
||||
* 测试 @ConfigurationProperties 注解的配置属性类
|
||||
*/
|
||||
@GetMapping("/test01")
|
||||
public OrderProperties test01() {
|
||||
return orderProperties;
|
||||
}
|
||||
|
||||
// @NacosValue(value = "${order.pay-timeout-seconds}")
|
||||
@Value(value = "${order.pay-timeout-seconds}")
|
||||
@Value(value = "${order.pay-timeout-seconds}") // @NacosValue(value = "${order.pay-timeout-seconds}")
|
||||
private Integer payTimeoutSeconds;
|
||||
|
||||
// @NacosValue(value = "${order.create-frequency-seconds}")
|
||||
@Value(value = "${order.create-frequency-seconds}")
|
||||
@Value(value = "${order.create-frequency-seconds}") // @NacosValue(value = "${order.create-frequency-seconds}")
|
||||
private Integer createFrequencySeconds;
|
||||
|
||||
// 测试 @Value 注解的属性
|
||||
/**
|
||||
* 测试 @Value 注解的属性
|
||||
*/
|
||||
@GetMapping("/test02")
|
||||
public Map<String, Object> test02() {
|
||||
return new JSONObject().fluentPut("payTimeoutSeconds", payTimeoutSeconds)
|
||||
|
||||
@@ -4,6 +4,7 @@ spring:
|
||||
|
||||
cloud:
|
||||
nacos:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
|
||||
namespace: # 使用的 Nacos 的命名空间,默认为 null
|
||||
|
||||
Reference in New Issue
Block a user