JAVA全系列 教程
3762个小节阅读:7092.6k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
服务端开发最主要的任务是配置从哪里读取对应的配置文件,我们将配置从Git仓库读取配置文件。
config-dev.yml
xxxxxxxxxx
config:
info: "master branch,config-dev.yml version=1"
config-test.yml
xxxxxxxxxx
config:
info: "master branch,config-test.yml version=1"
config-prod.yml
xxxxxxxxxx
config:
info: "master branch,config-prod.yml version=1"
xxxxxxxxxx
<dependencies>
<!-- 引入Eureka client依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- 引入 config 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<!-- 引入 web 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
</dependencies>
新增application.yml
xxxxxxxxxx
server:
port: 3344
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: https://gitee.com/WCCRegistered/cloud-config.git
search-paths:
- cloud-config
label: master
eureka:
client:
# 表示是否将自己注册到Eureka Server
register-with-eureka: true
# 示是否从Eureka Server获取注册的服务信息
fetch-registry: true
# Eureka Server地址
service-url:
defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka
instance:
instance-id: cloud-config-center
prefer-ip-address: true
xxxxxxxxxx
package com.itbaizhan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
/**
* 主启动类
*/
@Slf4j
@SpringBootApplication
@EnableConfigServer
public class ConfigCenterMain3344 {
public static void main(String[] args) {
SpringApplication.run(ConfigCenterMain3344.class,args);
log.info("*********** 配置中心服务启动成功 *************");
}
}
http://locahost:3344/config-dev.yml
1.Spring Cloud Config项目配置具体存放在____。
A redis
B mysql
C git
D svn
1=>C