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

兰州网站建设专家做网站拉客户有效吗

兰州网站建设专家,做网站拉客户有效吗,华容县住房和城乡建设局网站,十大骗子教育培训机构根据公司要求,需要将项目集成到nacos中,当前项目是基于若依前后端分离版开发的,若依的版本为3.8.3,若依框架中整合的springBoot版本为2.5.14。Nacos核心提供两个功能:服务注册与发现,动态配置管理。 一、服…

        根据公司要求,需要将项目集成到nacos中,当前项目是基于若依前后端分离版开发的,若依的版本为3.8.3,若依框架中整合的springBoot版本为2.5.14。Nacos核心提供两个功能:服务注册与发现,动态配置管理。


一、服务注册与发现

1、引入pom依赖

     </dependency>--><!-- 在SpringBoot 2.4.x的版本之后,对配置文件加载方式进行了重构,需要导入如下的依赖;详情见官网:https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#config-first-bootstrap --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.0.1</version></dependency><!-- 服务注册与发现依赖 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.1</version></dependency>

2、bootstrap.yml配置

spring:# nacos配置cloud:nacos:discovery:server-addr: 10.2.XX.XX:8848compatibility-verifier:enabled: false

3、添加注解

在项目启动类上添加 @EnableDiscoveryClient 注解:

@EnableDiscoveryClient
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RiskExamineApplication
{public static void main(String[] args){// System.setProperty("spring.devtools.restart.enabled", "false");SpringApplication.run(RiskExamineApplication.class, args);System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" +" .-------.       ____     __        \n" +" |  _ _   \\      \\   \\   /  /    \n" +" | ( ' )  |       \\  _. /  '       \n" +" |(_ o _) /        _( )_ .'         \n" +" | (_,_).' __  ___(_ o _)'          \n" +" |  |\\ \\  |  ||   |(_,_)'         \n" +" |  | \\ `'   /|   `-'  /           \n" +" |  |  \\    /  \\      /           \n" +" ''-'   `'-'    `-..-'              ");}
}

4、验证

        项目启动后,登录nacos,在服务列表中,点击查询即可看到注册到nacos的服务,如下图:

服务名默认为yml配置里spring.application.name的名称,也可通过spring.cloud.nacos.discovery.service配置指定。

遇到问题:Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.5.14] is not compatible with this Spring Cloud release train

Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] 


***************************
APPLICATION FAILED TO START
***************************Description:Your project setup is incompatible with our requirements due to following reasons:- Spring Boot [2.5.14] is not compatible with this Spring Cloud release trainAction:Consider applying the following actions:- Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn]. 
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]

解决办法:出现这个问题是由于springBoot和springCloud版本不一致导致的,如果是自己手动搭建的框架,可以根据提示将springBoot版本降到[2.3.x, 2.4.x];但是由于我用的是若依的框架,担心将springBoot版本降低后会引起其它问题,所以根据提示设置spring.cloud.compatibility-verifier.enabled=false这个属性,但是引入后发现配置不生效,最后根据研究一番之后,根据网上的提示需将配置文件名称application.yml改为bootstrap.yml,然后再引入依赖spring-cloud-starter-bootstrap 即可解决。

注意:如果只需要nacos的服务注册与发现功能,不用服务配置功能的话,一定要将服务配置的pom依赖(spring-cloud-starter-alibaba-nacos-config)去掉,否则启动时会报错:currentServerAddr:http://localhost:8848, err : connect timed out 。

二、服务动态配置与服务注册发现

1、引入pom依赖

  <!-- nacos --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2021.1</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.0.1</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.1</version></dependency>

2、bootstrap.yml配置

spring:cloud:nacos:discovery:server-addr: 124.70.XX.XX:32389namespace: zs-smartgroup: devconfig:server-addr: 124.70.XX.XX:32389namespace: zs-smartgroup: devname: zs-smartfile-extension: yamlcompatibility-verifier:enabled: false

3、nacos配置

1)新建命名空间

 2) 新建配置

打开配置列表,选择刚刚创建的zs-smart,点击右上角的“+”号,如下图:

3)填写配置

然后启动项目,如果项目启动成功,即说明配置没问题! 

参考文章:Springboot集成Nacos2「服务注册与发现」 - 知乎

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

相关文章:

  • 网站的备案快速建站工具
  • 做电子商务系统网站荣耀手机官方官网
  • 建设公司网站哪家好建设商城网站费用
  • 甘肃省两学一做专题网站上海网站建设联系
  • 设计发明的网站营销型网站建设要求
  • 商城网站开发业务企业网站被转做非法用途
  • 酷虎云建站工具视频软件下载app
  • 上海最好的网站设计公司俄罗斯军事新闻最新消息
  • 无锡企业推广网站网站可不可以做自己的专利
  • 网站需求分析模板2024年1月新冠高峰期
  • 临海企业网站建设公司类似享设计的网站
  • 资讯网站策划怎么写不同类型的购物网站
  • 用dw设计网站模板下载地址网站改中文
  • shopex 网站搬家wordpress小蜜蜂插件
  • shopify建站公司ui设计课程内容
  • 做网站服务器在哪买电脑外设网站建设论文
  • 怎么建立网站数据库连接建设外包网站
  • 东莞效果好的网站建设房地产建筑公司网站
  • 岳阳网站开发建设定制网站哪个好
  • 石家庄西晨网站开发软件外包行业分析
  • 有没有专门做网站的基于lamp网站建设实例
  • 湖北网站推广公司渠道机械加工网18易3下7拉nrj
  • 怎样创建网站dw中国建设网站银行
  • 苏州企业如何建网站太原网站优化推广
  • 网上购物网站建设规划菜鸟制作个人网站网页实例
  • 武侯区网站建设app拉新推广平台有哪些
  • 怎样创建个人销售网站wordpress单页留言
  • 有道云笔记做网站邢台网站建设有哪些
  • 网站备案ps叫企业做的网站可不可以自己改主题
  • 写作网站中国建筑网官网投诉查询