<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>


  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
@EnableConfigServer  //开启统一配置中心服务
@EnableEurekaClient  //Eureka的服务发现
@SpringBootApplication
public class SpringcloudConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringcloudConfigServerApplication.class, args);
    }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
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/   #注册中心地址
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.