nacos配置中心詳解,Nacos教程_4 配置講解

 2023-12-06 阅读 23 评论 0

摘要:教程原稿 https://gitee.com/fakerlove/joker-nacos 文章目錄4. 配置講解4.1 dataid 配置講解4.2 實現自動裝填 4. 配置講解 4.1 dataid 配置講解 在 Nacos Spring Cloud 中,dataId 的完整格式如下: ${prefix}-${spring.profiles.active}.${file-extension} pr

教程原稿 https://gitee.com/fakerlove/joker-nacos

文章目錄

  • 4. 配置講解
    • 4.1 dataid 配置講解
    • 4.2 實現自動裝填

4. 配置講解

4.1 dataid 配置講解

在 Nacos Spring Cloud 中,dataId 的完整格式如下:

${prefix}-${spring.profiles.active}.${file-extension}
  • prefix 默認為 spring.application.name 的值,也可以通過配置項 spring.cloud.nacos.config.prefix來配置。
  • spring.profiles.active 即為當前環境對應的 profile,詳情可以參考 Spring Boot文檔。 注意:當 spring.profiles.active 為空時,對應的連接符 - 也將不存在,dataId 的拼接格式變成 ${prefix}.${file-extension}
  • file-exetension 為配置內容的數據格式,可以通過配置項 spring.cloud.nacos.config.file-extension 來配置。目前只支持 propertiesyaml 類型。

4.2 實現自動裝填

package cn.com.geostar.datasource;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;/*** @author xiawei* @date 2020/8/10 11:33*/@Component
@RefreshScope
@ConfigurationProperties(prefix = "jedispool.config")
public class JedisPoolConfigure {private boolean enable;private String host;private Integer port;private String password;private Integer timeOut;private Integer maxIdle;private Integer maxWaitMillis;private Integer maxTotal;
}

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/189107.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息