Config-Server统一配置中心搭建
原创
©著作权归作者所有:来自51CTO博客作者mb650949ff24157的原创作品,请联系作者获取转载授权,否则将追究法律责任
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--引入统一配置中心-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<!--这个包是用来做健康监控的-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--将配置服务注册到eureka上面-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
@EnableConfigServer //开启统一配置中心服务
@EnableEurekaClient //Eureka的服务发现
@SpringBootApplication
public class SpringcloudConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringcloudConfigServerApplication.class, args);
}
}
server:
port: 8888 #服务注册中心端口号
spring:
application:
name: config-server #服务名称id
cloud:
config:
server:
git:
uri: https://gitee.com/username/config-server.git
default-label: master #默认是master 分支
searchPaths: config #远程仓库的文件夹地址
username: username #仓库用户名
password: password #仓库密码
eureka:
client:
service-url:
defaultZone: http://localhost:8080/eureka/ #注册中心地址