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

政务网站开发武汉seo创造者

政务网站开发,武汉seo创造者,天津百度,wordpress优化网站目录 一、问题现象 二、解决方案 三、运行结果 四、代码地址 一、问题现象 springcloud configClient获取configServer信息失败导致启动configClient注入失败 报错堆栈信息 org.springframework.beans.factory.BeanCreationException: Error creating bean with name scop…

目录

一、问题现象

二、解决方案

三、运行结果

四、代码地址


一、问题现象

springcloud configClient获取configServer信息失败导致启动configClient注入失败

报错堆栈信息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.testController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'version' in value "${version}"

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'version' in value "${version}"

二、解决方案

经排查,原因为gitee配置文件名config-dev.properties与服务注册名不一致导致,bootstrap.yml配置了configServer地址之后,configClient从gitee中获取配置文件的时候指定了profile(dev哪个环境)以及label(newBranch4分支),但是configServer获取配置文件的时候会批量加载所有分支的配置文件信息,因此configClient和configServer配置文件关联必须由服务名以及文件名关联,因此在修改gitee中配置文件的文件名为服务名之后,configClient启动成功,并成功获取gitee中相关配置信息。

gitee中配置文件内容

git clone https://gitee.com/fzggz/springcloud.git

configServer工程的bootstrap.yml

spring:profiles:active: devapplication:name: config-servercloud:config:label: newBranchserver:git:uri: https://gitee.com/fzggz/springcloudsearchPaths: spring-cloud-config-filetimeout: 60username: ***password: ***default-label: newBranch
eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/
bobo:user:name: boboage: 18

configClient的bootstrap.yml

spring:application:name: config-clientcloud:config:uri: http://127.0.0.1:8030  # 直接连接 Config-Serverprofile: devlabel: newBranch3discovery:enabled: false
#        enabled: true
#        service-id: config-server
eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/

三、运行结果

configClient配置客户端代码,启动configClient后,读取configServer中读取到的配置文件信息,通过文件名,profile,label等映射关系找到version,通过@Value注入version,controller中获取

package com.ggz.configclient.controller;import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @author ggz on 2025/4/1*/
@RefreshScope
@RestController
public class TestController {@Value("${version}")private String version;@RequestMapping("/version")public String version() {return version;}
}

四、代码地址

直接导入,启动eureka和configServer以及configClient即可

https://github.com/GeGuozhi/SpringCloudDemo.git

希望有用的同时大家能帮忙能点亮一个小小的star

http://www.dtcms.com/wzjs/144353.html

相关文章:

  • wordpress 速度很慢马鞍山seo
  • 新疆示范工程建设服务平台网站哪个平台可以接推广任务
  • 建设网站出现400错误自媒体发稿
  • 网站焦点图如何美观广州seo诊断
  • c语言 做网站网站老域名跳转到新域名
  • 网站开发后端做那些国通快速建站
  • 深圳网站建设卓企成都全网营销推广
  • 中小企业网站提供了什么成品网站seo
  • ftp怎么连接网站空间兰州seo整站优化服务商
  • 平度那里有做网站的百度关键词刷排名软件
  • 淘宝客优惠卷网站模板提高工作效率的软件
  • 做一个商城网站需要提交那些文件seo百科大全
  • 装修公司做推广网站怎么弄网站优化塔山双喜
  • 做网站从何开始最近的新闻大事20条
  • 东莞做企业网站友情下载网站
  • 七里港网站建设互联网推广渠道有哪些
  • 外链的论坛网站站长统计幸福宝下载
  • 佛山外贸网站制作公司最新军事报道
  • 电白网站开发公司网站推广优化教程
  • 有了云服务器怎么做网站百度服务中心电话
  • 购物网站及app开发黄冈seo顾问
  • 百度seo排名点击seo推广营销靠谱
  • 官方网站开发商seo的方式包括
  • php网站开发建设seo关键词怎么选
  • 辽阳做网站的公司微信朋友圈推广软文
  • 长春高铁站桂林seo排名
  • 网站权重传递北京网站优化推广方案
  • phpwind能做网站吗网站内部优化有哪些内容
  • b2b网站产品群发工具百度广告点击软件
  • 用群晖做网站服务器小型项目外包网站