Config-Server配置项的服务端

1.pom.xml

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.SR1</spring-cloud.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
    </dependencies>

2、启动类

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }

}

3、application.yml

server:
  port: 8080
spring:
  cloud:
    config:
      server:
        git:
#          uri: git@github.com:wangchunself/ymlforconfig.git
          uri: https://github.com/wangchunself/ymlforconfig.git
          skipSslValidation: true

单独使用git@github.com:wangchunself/ymlforconfig.git也就是不配置skipSslValidation: true的情况下,报错,当然,这种模式,配置了skipSslValidation: true也是错。

单独使用https://github.com/wangchunself/ymlforconfig.git也就是不配置skipSslValidation: true的情况下,也报错,但是在使用https://github.com/wangchunself/ymlforconfig.git同时配置skipSslValidation: true,则项目正常显示

3中情况均是报错Cannot clone or checkout repository

具体错误原因也没整明白,错误解决来自https://blog.csdn.net/jianzaiyu/article/details/84455645,可自行查看一下

 

4、映射规则

/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties

5、我的github上传了两个文件

其中文件名的命名格式和请求格式对应起来就是

application-profile.properties或者application-profile.yml

请求一:http://localhost:8080/master/adc-adc.propertieshttp://localhost:8080/master/adc-adc.yml

请求二:http://localhost:8080/master/foo-bar.ymlhttp://localhost:8080/master/foo-bar.properties

请求三:http://localhost:8080/adc/adc/master

请求四:http://localhost:8080/foo/bar/master

请求一中的两个请求因为它的application部分和profile部分都找不到,就会拿去默认文件application.properties或者application.yml中的内容

请求二中的两个请求因为有对应的文件,所以会拿到对应文件中的内容

请求三得到如图示

只有默认文件中的内容

请求四得到如图示

有默认文件和对应文件中的内容

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值