spring cloud 配置中心客户端启动遇到的问题
作者:qq_36481502 发布时间:2023-03-23 16:30:34
标签:spring,cloud,配置,客户端,启动
spring cloud 配置中心客户端启动
先启动了配置中心,然后启动客户端,
发现打印的日志是这样的
2020-04-29 11:13:02.333 INFO 1856 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9009/
2020-04-29 11:13:08.121 INFO 1856 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=test-config, profiles=[dev], label=master, version=3eb2b779d066af89af4ba5b7a722d2189a15ffd3, state=null
2020-04-29 11:13:08.122 INFO 1856 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #1)'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #0)'}]
2020-04-29 11:13:08.127 INFO 1856 --- [ main] c.z.c.ConfigCloudClientApplication : The following profiles are active: dev
2020-04-29 11:13:08.408 INFO 1856 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=3bad3006-6836-326e-9ae4-7b60b788ec28
2020-04-29 11:13:08.720 INFO 1856 --- [ main] c.z.c.ConfigCloudClientApplication : Started ConfigCloudClientApplication in 7.436 seconds (JVM running for 8.236)
从日志上看,已经获取到了配置中心的配置,但是呢,总感觉日志不对,怎么就没有启动的端口呢。
springcloud经常会一个模块包含另外模块,难道web模块没有被 spring-cloud-starter-config 包含?
那就加入web模块吧
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
加入之后再启动项目
2020-04-29 11:20:35.379 INFO 10060 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9009/
2020-04-29 11:20:36.849 INFO 10060 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=test-config, profiles=[dev], label=master, version=3eb2b779d066af89af4ba5b7a722d2189a15ffd3, state=null
2020-04-29 11:20:36.850 INFO 10060 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #1)'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #0)'}]
2020-04-29 11:20:36.855 INFO 10060 --- [ main] c.z.c.ConfigCloudClientApplication : The following profiles are active: dev
2020-04-29 11:20:37.278 INFO 10060 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=21eb9db3-9e16-3c20-bd81-2c0ea23b0f12
2020-04-29 11:20:37.566 INFO 10060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8201 (http)
2020-04-29 11:20:37.574 INFO 10060 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-29 11:20:37.574 INFO 10060 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-04-29 11:20:37.684 INFO 10060 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-04-29 11:20:37.684 INFO 10060 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 817 ms
2020-04-29 11:20:37.851 INFO 10060 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-29 11:20:38.200 INFO 10060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8201 (http) with context path ''
2020-04-29 11:20:38.285 INFO 10060 --- [ main] c.z.c.ConfigCloudClientApplication : Started ConfigCloudClientApplication in 3.87 seconds (JVM running for 4.531)
果然,从配置中心拉取到了配置并成功启动了。
spring cloud配置中心客户端配置的坑
1. 出错信息如下
在启动配置中心的客户端时,报以下错误信息:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"
2. 度娘查了下,发现很多人碰到这个坑
首先我提交到git上到配置文件名称为下面两个文件
cloud-config-dev.properties
cloud-config-test.properties
遵循配置中心配置文件的规则/{application}-{profile}.properties
所以在cloud-config-client端调用的时候,applcation.name应该是cloud-config,然而我在配置的时候,想当然的写成了cloud-config-client,导致出现上面的错误。
解决方法很简单,贴下client的配置如下
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
来源:https://blog.csdn.net/qq_36481502/article/details/105835515


猜你喜欢
- 使用包管理器package com.liunan.myfirstapp.util;import android.content.Contex
- 本文实例讲述了Java基于动态规划法实现求最长公共子序列及最长公共子字符串。分享给大家供大家参考,具体如下:动态规划法经常会遇到复杂问题不能
- 1.情景展示java发送get请求、post请求(form表单、json数据)至另一服务器;可设置HTTP请求头部信息,可以接收服务器返回c
- 前言对于Android播放一些简短音效,例如提示音,或者铃声,相对于使用MediaPlayer,SoundPool可以节省更多资源,并且可以
- 这篇文章主要介绍了MyBatis传入数组集合类并使用foreach遍历,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学
- 虹软免费,高级版本试用支持在线、离线有 Java SDK,C++ SDK一、注册虹软开发者平台点击注册注册完成后可在“我
- 最近在做报表统计方面的需求,涉及到行转列报表。根据以往经验使用SQL可以比较容易完成,这次决定挑战一下直接通过代码方式完成行转列。期间遇到几
- 简介CAS的原理其实很简单,为了保证在多线程环境下我们的更新是符合预期的,或者说一个线程在更新某个对象的时候,没有其他的线程对该对象进行修改
- 实例如下:/** * 将一个list均分成n个list,主要通过偏移量来实现的 * @param source * @return */ p
- 前言相信很多人对枚举并不陌生,枚举可以很方便和直观的管理一组特定值。如果我们在页面上直接输出我们希望匹配的汉语意思或则其他满足我们需求的语句
- 区别1.使用范围和规范不同filter是servlet规范规定的,只能用在web程序中. * 即可以用在web程序中, 也可以用于appli
- 写了一个可以扫描附近蓝牙设备的小Demo,可以查看蓝牙设备的设备名和Mac地址代码量不多,很容易看懂/** * 作者:叶应是叶 * 时间:2
- 一、前言关于EasyExcel,它对poi做了进一步的封装,使得整个编写流程更加的面向对象。好处嘛,我认为流程上更加清晰即易懂、可读性更好,
- Android 定时器实现图片的变换在Android中,要让每秒进行一次ui更新,就需要利用到定时器和handler,message的结合,
- 这篇文章主要介绍了简单了解Java中的可重入锁,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参
- 数组与链表的比较:数组通过下标访问的话是O(1)数组一旦声明 长度就是固定的数组的数据是物理逻辑均连续的链表增删要快一些, 数组遍历快一些长
- 概述对象实例由对象头、实例数据组成,其中对象头包括markword和类型指针,如果是数组,还包括数组长度;| 类型 | 32位JVM | 6
- 在学习了不少使用string处理字符串的方法后,对于这方面基础内容模块已经初步掌握。对于java面试时,字符串是比较基础和重点的模块,所以在
- 1. 为什么写这篇文章?事情是这样的,在 2021年6月10日早上我在CSDN上发布了文章《你真的懂Java怎么输出Hello World吗
- CLR要求每一个类型都最终从object类型派生,如下: class Typer {} === class Typer :object {}