教程原稿 https://gitee.com/fakerlove/joker-nacos
在 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
來配置。目前只支持 properties
和 yaml
類型。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;
}
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态