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了,需要修改配置文件

    仓库
  • 相关阅读:
    一个仿windows泡泡屏保的实现
    易语言中锐浪报表绿色发布指南(免COM组件DLL注册)
    服务器被攻击小记
    aidl.exe'' finished with non-zero exit value 1问题解决【转载】
    给APP增加RSA签名
    fastreport中文乱码问题
    EF join
    ActionFilter、IAuthorizationFilter 权限验证重定向跳转到其它页面
    EF 调试跟踪生成的SQL语句
    Asp.net MVC 权限验证,以及是否允许匿名访问
  • 原文地址:https://www.cnblogs.com/NaoDaiYouDianDa/p/13985354.html
Copyright © 2011-2022 走看看