zoukankan      html  css  js  c++  java
  • springcloud(6)-配置服务器

    1.创建config-server

    image-20201116105906570

    2.pom.xml配置

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <groupId>com.zhangdemo</groupId>
        <artifactId>springcloud</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </parent>
      <artifactId>configServer</artifactId>
    
      <dependencies>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <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>
    
      </dependencies>
    </project>
    

    3.ConfigServerApplication加入@EnableConfigServer

    package com.zhangdemo;
    
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
    import org.springframework.cloud.config.server.EnableConfigServer;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
    
    import cn.hutool.core.util.NetUtil;
    
    @SpringBootApplication
    @EnableConfigServer
    @EnableDiscoveryClient
    @EnableEurekaClient
    public class ConfigServerApplication {
        public static void main(String[] args) {
            int port = 8030;
            if(!NetUtil.isUsableLocalPort(port)) {
                System.err.printf("端口%d被占用了,无法启动%n", port );
                System.exit(1);
            }
            new SpringApplicationBuilder(ConfigServerApplication.class).properties("server.port=" + port).run(args);
    
        }
    }
    

    4.application.yml

    spring:
      application:
        name: config-server
      cloud:
        config:
          server:
            git:
              uri: https://github.com/zhangkaixing/springcloudConfig
              searchPaths: respo
              default-label: main
    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/
    

    5.测试http://localhost:8030/version/dev

    image-20201116110414946

    ps.出现的问题:

    1.仓库编程main了,需要修改配置文件

    仓库
  • 相关阅读:
    高斯消元学习
    HDU 4596 Yet another end of the world(解一阶不定方程)
    Codeforces Round #318 div2
    HDU 4463 Outlets(一条边固定的最小生成树)
    HDU 4458 Shoot the Airplane(计算几何 判断点是否在n边形内)
    HDU 4112 Break the Chocolate(简单的数学推导)
    HDU 4111 Alice and Bob (博弈)
    POJ 2481 Cows(线段树单点更新)
    HDU 4288 Coder(STL水过)
    zoj 2563 Long Dominoes
  • 原文地址:https://www.cnblogs.com/NaoDaiYouDianDa/p/13985354.html
Copyright © 2011-2022 走看看