diff --git a/pom.xml b/pom.xml index 3ba6100..59dfda7 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ 3.12.0 2.0.0 3.0.5 + 0.3.0-RC @@ -190,6 +191,12 @@ jasypt-spring-boot-starter ${jasypt-starter.version} + + + com.alibaba.boot + nacos-config-spring-boot-starter + ${nacos-config.version} + diff --git a/xiaoyi-auth/pom.xml b/xiaoyi-auth/pom.xml index d1544ad..4f89a34 100644 --- a/xiaoyi-auth/pom.xml +++ b/xiaoyi-auth/pom.xml @@ -96,6 +96,12 @@ org.springframework.boot spring-boot-starter-actuator + + + + com.alibaba.boot + nacos-config-spring-boot-starter + diff --git a/xiaoyi-auth/src/main/java/top/crushtj/xiaoyishu/auth/controller/TestController.java b/xiaoyi-auth/src/main/java/top/crushtj/xiaoyishu/auth/controller/TestController.java new file mode 100644 index 0000000..c4d38c1 --- /dev/null +++ b/xiaoyi-auth/src/main/java/top/crushtj/xiaoyishu/auth/controller/TestController.java @@ -0,0 +1,19 @@ +package top.crushtj.xiaoyishu.auth.controller; + +import com.alibaba.nacos.api.config.annotation.NacosValue; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +public class TestController { + + @NacosValue(value = "${rate-limit.api.limit}",autoRefreshed = true) + private Integer limit; + + @GetMapping("/test") + public String test() { + return "当前限流阈值为: " + limit; + } +} diff --git a/xiaoyi-auth/src/main/resources/config/application-dev.yml b/xiaoyi-auth/src/main/resources/config/application-dev.yml index c67f109..1419495 100644 --- a/xiaoyi-auth/src/main/resources/config/application-dev.yml +++ b/xiaoyi-auth/src/main/resources/config/application-dev.yml @@ -82,4 +82,20 @@ jasypt: key-obtention-iterations: 1000 string-output-type: base64 provider-name: SunJCE - iv-generator-classname: org.jasypt.iv.RandomIvGenerator \ No newline at end of file + iv-generator-classname: org.jasypt.iv.RandomIvGenerator +nacos: + config: # Nacos 配置中心 + access-key: # 身份验证 + secret-key: # 身份验证 + data-id: xiaoyishu-auth # 指定要加载的配置数据的 Data Id + group: DEFAULT_GROUP # 指定配置数据所属的组 + type: yaml # 指定配置数据的格式 + server-addr: http://127.0.0.1:8848/ # 指定 Nacos 配置中心的服务器地址 + auto-refresh: true # 是否自动刷新配置 + remote-first: true # 是否优先使用远程配置 + bootstrap: + enable: true # 启动时,预热配置 + +rate-limit: + api: + limit: 100 # 接口限流阈值 \ No newline at end of file