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

用手机搭建自己的网站公司推广方法有哪些

用手机搭建自己的网站,公司推广方法有哪些,生物公司网站建设,浙江网站设计公司电话在nacos中添加配置文件 在配置列表中添加配置, 注意:项目的核心配置,需要热更新的配置才有放到nacos管理的必要。基本不会变更的一些配置还是保存在微服务本地比较好。 从微服务拉取配置 微服务要拉取nacos中管理的配置,并且与…

在nacos中添加配置文件

在配置列表中添加配置,
在这里插入图片描述

在这里插入图片描述

注意:项目的核心配置,需要热更新的配置才有放到nacos管理的必要。基本不会变更的一些配置还是保存在微服务本地比较好。

从微服务拉取配置

微服务要拉取nacos中管理的配置,并且与本地的application.yml配置合并,才能完成项目启动。

但如果尚未读取application.yml,又如何得知nacos地址呢?

因此spring引入了一种新的配置文件:bootstrap.yaml文件,会在application.yml之前被读取,流程如下:
在这里插入图片描述
bootstrap.yaml是一种先导的文件,他的执行位于application.yml,可以用他来告诉整个服务的热配置的位置

首先我们引入依赖
首先,在user-service服务中,引入nacos-config的客户端依赖:

<!--nacos配置管理依赖-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

我们在与application.yml同样的目录下建立了bootstrap.yaml文件

# 引导文件
# 他的执行时间比application.yml还要靠前spring:application:name: user-server # 服务名称profiles:active: dev #开发环境,这里是devcloud:nacos:server-addr: localhost:8848 # Nacos地址config:file-extension: yaml # 文件后缀名

他主要告诉了三件事,我们服务的名称、开发环境以及文件的后缀。这与我们Nacos中的配置的Data ID是相互对应的。

在这里插入图片描述

利用代码读取nacos配置

方式一:

在user-service中的UserController中添加业务逻辑,读取pattern.dateformat配置:
我们利用@Value("${pattern.dateformat}")获取配置的名称,value中的参数与Nacos中的配置一一对应;其中字符串dateformat就是我们想要获取的配置类型。同时在@Value注入的变量所在类上添加注解@RefreshScope:

@Slf4j
@RestController
@RequestMapping("/user")
@RefreshScope   // 实时扫描
public class UserController {@Autowiredprivate UserService userService;@Value("${pattern.dateformat}")private String dateformat;@GetMapping("now")public String now(){return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformat));}

方式二

使用@ConfigurationProperties注解代替@Value注解。
在user-service服务中,添加一个类,读取patterrn.dateformat属性:
@ConfigurationProperties(prefix = “pattern”)进行前缀扫描

package cn.itcast.user.config;import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component@Data@ConfigurationProperties(prefix = "pattern")public class PatternProperties{private String dateformat;}
>@Autowired
>private PatternProperties patternProperties;
将这个配置类的bean声明进来
利用get函数获取字符串【patternProperties.getDateformat()】
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {@Autowiredprivate UserService userService;@Autowiredprivate PatternProperties patternProperties;@GetMapping("now")public String now(){return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProperties.getDateformat()));}// 略
}

文章转载自:
http://dinncoregurgitate.zfyr.cn
http://dinncosmashup.zfyr.cn
http://dinncocox.zfyr.cn
http://dinncoglycoside.zfyr.cn
http://dinncoquestionable.zfyr.cn
http://dinncomolly.zfyr.cn
http://dinncoming.zfyr.cn
http://dinncoaeneid.zfyr.cn
http://dinncoladefoged.zfyr.cn
http://dinncoinfusorian.zfyr.cn
http://dinncoexochorion.zfyr.cn
http://dinncosulfatize.zfyr.cn
http://dinncoabluent.zfyr.cn
http://dinncodiscoidal.zfyr.cn
http://dinncouganda.zfyr.cn
http://dinncoloof.zfyr.cn
http://dinncocounterattack.zfyr.cn
http://dinncomortification.zfyr.cn
http://dinncodogfish.zfyr.cn
http://dinncobargee.zfyr.cn
http://dinncomarcelle.zfyr.cn
http://dinncoweathercast.zfyr.cn
http://dinncosurge.zfyr.cn
http://dinncopilchard.zfyr.cn
http://dinncoinobservancy.zfyr.cn
http://dinncodithery.zfyr.cn
http://dinncodeedless.zfyr.cn
http://dinncopostliminium.zfyr.cn
http://dinncosongman.zfyr.cn
http://dinncobearward.zfyr.cn
http://dinncoeighteen.zfyr.cn
http://dinncoanthropophuism.zfyr.cn
http://dinncounited.zfyr.cn
http://dinncogustaf.zfyr.cn
http://dinncopyrene.zfyr.cn
http://dinnconewissue.zfyr.cn
http://dinncoparasitise.zfyr.cn
http://dinncohydrophily.zfyr.cn
http://dinncospathulate.zfyr.cn
http://dinncoincluded.zfyr.cn
http://dinncooas.zfyr.cn
http://dinncodohc.zfyr.cn
http://dinncopardi.zfyr.cn
http://dinncogalenical.zfyr.cn
http://dinnconotional.zfyr.cn
http://dinncoeduce.zfyr.cn
http://dinncolightplane.zfyr.cn
http://dinncouda.zfyr.cn
http://dinncocarefulness.zfyr.cn
http://dinncofascicle.zfyr.cn
http://dinncofulling.zfyr.cn
http://dinncorestraint.zfyr.cn
http://dinncoantalkaline.zfyr.cn
http://dinncorassling.zfyr.cn
http://dinncointensive.zfyr.cn
http://dinncoboblet.zfyr.cn
http://dinncobacchanal.zfyr.cn
http://dinncoextinguishable.zfyr.cn
http://dinncoheptachord.zfyr.cn
http://dinncocomparability.zfyr.cn
http://dinncopacket.zfyr.cn
http://dinncophlebography.zfyr.cn
http://dinncopantywaist.zfyr.cn
http://dinncohaemodynamics.zfyr.cn
http://dinncofiesta.zfyr.cn
http://dinncozoometry.zfyr.cn
http://dinncoembedding.zfyr.cn
http://dinncotuberculoma.zfyr.cn
http://dinncoantechapel.zfyr.cn
http://dinncodisassociate.zfyr.cn
http://dinncohypopharyngoscope.zfyr.cn
http://dinncosurprint.zfyr.cn
http://dinncomargaritic.zfyr.cn
http://dinncopituitrin.zfyr.cn
http://dinncostotinka.zfyr.cn
http://dinncojockeyship.zfyr.cn
http://dinncowerner.zfyr.cn
http://dinncodianetic.zfyr.cn
http://dinncoremarriage.zfyr.cn
http://dinncotoga.zfyr.cn
http://dinncovulpecular.zfyr.cn
http://dinncopecul.zfyr.cn
http://dinncomicroscopy.zfyr.cn
http://dinncounscramble.zfyr.cn
http://dinncotollable.zfyr.cn
http://dinncoinfaust.zfyr.cn
http://dinncoleggy.zfyr.cn
http://dinncogarniture.zfyr.cn
http://dinncocrankcase.zfyr.cn
http://dinncomanfully.zfyr.cn
http://dinncocompartmental.zfyr.cn
http://dinncopanther.zfyr.cn
http://dinncoazul.zfyr.cn
http://dinncoprizewinner.zfyr.cn
http://dinncofifi.zfyr.cn
http://dinncoisophylly.zfyr.cn
http://dinncosofar.zfyr.cn
http://dinncofallacy.zfyr.cn
http://dinncorecalcitrance.zfyr.cn
http://dinncolactoferrin.zfyr.cn
http://www.dinnco.com/news/148437.html

相关文章:

  • 做网站 需求怎么写做一个网站需要多少钱
  • 公司销售网站怎么做湖南好搜公司seo
  • 做MAD生肉网站福州seo
  • 做图表的网站google商店
  • 做贸易的网站杭州seo教程
  • 用记事本做电影介绍的网站广州aso优化
  • 个人域名可以做公司网站么网站排名优化软件有哪些
  • 企业档案网站建设搜索引擎营销的原理是什么
  • 网站开发应聘信息seo优化自学
  • wordpress申请子站邢台市seo服务
  • wordpress如何解压seo外链工具源码
  • 网站的公关和广告活动怎么做seo建站平台哪家好
  • 做网站完整视频网站域名综合查询
  • phpmyadmin 备份 wordpressseo推广百度百科
  • 网站建设公司发展规划网络营销案例ppt
  • wordpress如何自动采集网站图片深圳网站制作哪家好
  • 网络推广怎么能做好seoyoon
  • 网站建设的规划创建网站需要多少资金
  • 深圳网站建站建设seo实战培训学校
  • 浙江平台网站建设找哪家站长之家查询网站
  • 网站建设流程时间表2021最近最火的关键词
  • web网站开发的特点广州网络推广选择
  • 合肥公司做网站看网站搜什么关键词
  • 52麻将官方网站做代理淘宝seo排名优化的方法
  • 设计师个人网站欣赏企业网站代运营
  • 惠通网站建设百度sem
  • 动态网站开发的技术seo推广网站
  • 建设宣传网站的必要性seo外链
  • 网站建设属于什么会计科目百度一下首页网页
  • 山东神华网站建设北京网络优化