本项目中:
jdk版本:jdk1.8
springboot版本:2.3.10.RELEASE
springcloud版本:Hoxton.SR11
父工程
父工程下的config-center-8010(配置中心服务端)
父工程下的student-service-8011(配置中心客户端)

org.springframework.cloud
spring-cloud-config-server
没有写版本号是因为:父工程中声明了springcloud,springcloud中声明了spring-cloud-config-dependencies
此处以本地存储配置文件为例:
application.properties
# 服务端口
server.port=8010
# 服务名称
spring.application.name=config-center
# 配置config文件位置,native表示本地存储配置文件(还有svn,git方式等)
spring.profiles.active=native
spring.cloud.config.server.native.search-locations=classpath:/myconfig
图解:

@EnableConfigServer

到这里,配置中心服务端就搭建好了!
org.springframework.cloud
spring-cloud-starter-config
在resource文件夹下新建bootstrap.yml配置文件:
spring:
application:
name: student-service
profiles:
active: tzq
# 配置中心存放配置文件格式:${application.name}-${profiles.active}.yml
# 例如student-service-tzq.yml、student-service-tzq.properties
# 通过上述两个配置去配置中心读取对应的配置文件
cloud:
config:
# uri 配置中心服务地址
uri: http://localhost:8010
fail-fast: true

这里为什么用bootstrap.yml来添加配置,而不是application.properties。
因为:bootstrap.yml比application.yml的优先级要高,项目启动的时候就会执行,适合配置中心客户端使用,项目启动的时候去配置中心拉取配置信息。
在resource文件夹下新建文件夹myconfig,在myconfig文件夹下新建:student-service-tzq.properties文件

student-service-tzq.properties文件:
server.port=8011
# 服务名称
spring.application.name=student-service
# mysql数据库连接
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/tzq?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=Admin@123
# 配置actuator的访问端口,如果不配置则默认跟该服务运行端口一样
management.server.port=7802
# 配置actuator的info信息,info.后面可以自己随便定义
info.name=${spring.application.name}
info.tzq=tzq
到这里配置中心客户端也完成!
先启动配置中心服务端,再启动客户服务。

控制台显示:Fetching config from server at : http://localhost:8010
配置中心成功!!!