标签:mode 访问 str 类型 仓库 start serve and it路
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://gitee.com/qubaba/spring-cloud-config # git路径
username: # 私有仓库的话需要输入git的账号密码
password:
search-paths: /spring-cloud-config # 查找该路径下的所有文件
default-label: spring-cloud-config # 默认的分支
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
?
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
?
}
?
?
关键注解为:@EnableConfigServer
表示启动类为配置服务类。
访问到配置服务器的配置文件后会在本地生成一份配置文件的副本。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
spring cloud config 的配置文件需要提前加载所以需要在resources
目录下新建文件bootstrap.yml
文件
spring:
profiles:
active: dev # 默认加载配置文件
application:
name: config
cloud:
config:
uri: http://localhost:9000 # 配置服务器地址
name: ${spring.application.name} # application Name
profile: ${spring.profiles.active} # 那个类型的配置为文件
标签:mode 访问 str 类型 仓库 start serve and it路
原文地址:https://www.cnblogs.com/qubaba/p/10843201.html