整合nacos配置
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<dypnsapi.version>2.0.0</dypnsapi.version>
|
||||
<jasypt-starter.version>3.0.5</jasypt-starter.version>
|
||||
<nacos-config.version>0.3.0-RC</nacos-config.version>
|
||||
</properties>
|
||||
|
||||
<!-- 统一依赖管理 -->
|
||||
@@ -190,6 +191,12 @@
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>${jasypt-starter.version}</version>
|
||||
</dependency>
|
||||
<!-- Nacos配置中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<version>${nacos-config.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -96,6 +96,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Nacos 配置中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -83,3 +83,19 @@ jasypt:
|
||||
string-output-type: base64
|
||||
provider-name: SunJCE
|
||||
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 # 接口限流阈值
|
||||
Reference in New Issue
Block a user