当前位置: 首页 > news >正文

张家港做网站优化排名手机参数查询网站

张家港做网站优化排名,手机参数查询网站,国际物流公司网站,企业网站带商城源码再接入nacos配置中心时,需要确认几点: 1. spring boot 版本 (spring boot 2.x ) 2. nacos 配置中心 服务端 版本 (1.1.4) 3. nacos client 客户端版本 (1.1.4) 方式一 1. 启动 nacos 服务端,这里不做解释 在配置中心中加入几个配置 2. 在…

再接入nacos配置中心时,需要确认几点:

1. spring boot 版本 (spring boot 2.x )

2. nacos 配置中心 服务端 版本 (1.1.4)

3. nacos client 客户端版本 (1.1.4)

方式一

1. 启动 nacos 服务端,这里不做解释

在配置中心中加入几个配置

2. 在自己的应用里引入 依赖包

<dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.2.8</version></dependency>

注意, nacos-config-spring-boot-starter 的版本内 引入了 nacos-client,需要注意引入的版本 是否与nacos服务端匹配。如果不匹配,可能会有问题。

这里使用的 nacos 服务端 是 1.x版本,所有引入的包也是1.x的才可以。

3. 配置 nacos 服务端地址

nacos.config.server-addr= localhost:8848 

4.  在spring boot 启动类 加入 注解

如果是 只有一个 dataId,使用 @NacosPropertySource

如果有 多个 dataId,使用 @NacosPropertySources

@SpringBootApplication
@NacosPropertySources({@NacosPropertySource(dataId = "springboot-nacos-hello", autoRefreshed = true,type = ConfigType.PROPERTIES),@NacosPropertySource(dataId = "useLocalCache", autoRefreshed = true,type = ConfigType.PROPERTIES)
})
public class NacostestApplication {public static void main(String[] args) {SpringApplication.run(NacostestApplication.class, args);}}

5. 读取 配置

使用 注解 @NacosValue

    @NacosValue(value = "${hi}", autoRefreshed = true)private String useLocalCache;

方式二:

引入依赖

        <dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>1.1.4</version></dependency>

直接调用api

@Component
public class ConfigS {@Beanpublic ConfigService configService() {try {Properties properties = new Properties();properties.setProperty("serverAddr", "localhost:8848");ConfigService configService = NacosFactory.createConfigService(properties);configService.addListener("springboot-nacos-hello", "DEFAULT_GROUP", new Listener() {@Overridepublic Executor getExecutor() {return null;}@Overridepublic void receiveConfigInfo(String configInfo) {// 配置更新处理逻辑System.out.printf(configInfo);}});return configService;} catch (Exception e) {return null;}}
}
configService.getConfig("springboot-nacos-hello","DEFAULT_GROUP",10000)

这种方式 只是简单的拉去配置中心的内容,需要自己解析 配置内容和监听更新

方案三

引入依赖包

        <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2.1.1.RELEASE</version><exclusions><exclusion><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>1.1.4</version></dependency>

 在 bootstrap.properties 文件中配置属性:

#服务地址
spring.cloud.nacos.config.server-addr= localhost:8848#共享配置
spring.cloud.nacos.config.shared-dataids=a.properties,b.properties
spring.cloud.nacos.config.refreshable-dataids=a.properties#扩展配置
spring.cloud.nacos.config.ext-config.0.data-id=useLocalCache.properties
spring.cloud.nacos.config.ext-config.0.refresh=true
spring.cloud.nacos.config.ext-config.1.data-id=useLocalCache2.properties#当前应用
spring.cloud.nacos.config.prefix=app
spring.cloud.nacos.config.file-extension= properties

读取配置: 使用@Value 注解

@Value(value = "${hi}")
private String useLocalCache;

 

nacos配置中心添加配置

 

共有三种配置:

1. 加载共享配置

sharedDataids 注意: 需要有后缀

refreshableDataids

分隔符 "[,]"

2. 加载扩展配置

extConfig 数组结构

dataId 必须有后缀

3. 加载应用级别的配置

读取 prefix /name/spring.application.name 属性

作为dataId

1. 直接加载 dataId

2. 加载 dataId.fileExtension

3. 加载 dataId - profile . fileExtension

覆盖

http://www.yayakq.cn/news/143081/

相关文章:

  • 零基础怎么学网页设计石家庄seo
  • 网站建设需要了解哪些方面美化WordPress的导航
  • 萝岗营销型网站建设网站建设公司运营模式
  • 网站设计弹窗企业网页页面设计
  • 有没有专做游戏脚本的网站wordpress禁止360爬虫
  • asp.net ftp发布网站外贸订单在哪里能接到
  • 兰州市城乡建设局网站好玩有趣的网站
  • 网站app开发计划书金马国旅网站建设
  • 威海网站定制无极电影网怎样下载电影
  • 门户网站建设需求怎么建立一个网站放图片
  • daozicms企业建站系统莱芜雪野湖天气预报
  • 做网站asp和asp.netReviewer WordPress
  • 网站做蜘蛛池有用吗高端设计网站都有哪些
  • 如何做网站关键词收录做汽车售后的网站
  • 制作网站的网站商务网站开发流程有哪三个阶段
  • 平安保险网站alipay域名网站
  • 一流的网站建设哪家好阿里企业邮箱怎么用
  • 企业资质查询官方网站企业网站的主要栏目
  • 做淘客网站用什么上传文件wordpress 个人国内收款
  • 如何仿制手机版网站手机网站建设怎么设计
  • 网站风格定位小说系统+wordpress
  • 酷炫flash网站网站策划书的要点
  • 上海 企业网站制什么是网站开发流程
  • 网站怎么上传电子商务网站建设的步骤一般
  • 网站快速优化排名免费微信支付公司网站
  • 支付宝手机网站签约网络策划师是什么职业
  • 网站首页设计说明青羊区网站建设
  • 漯河网站建设(千弘网络)汕头自助建站系统
  • 中国十佳网站建设公司市场营销网站建设
  • 长沙外贸网站开发手机网站跳出率低