美文网首页
6.搭建配置中心Config-Server

6.搭建配置中心Config-Server

作者: 溅十三 | 来源:发表于2020-06-13 19:08 被阅读0次
image.png

1.创建config的文件夹

2.创建config-server的模块

image.png

3.pom依赖

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>spring-cloud-demo</artifactId>
        <groupId>org.example</groupId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>

    <groupId>com.imooc</groupId>
    <artifactId>config-server</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
    </dependencies>


</project>

4.启动类

package com.imooc.springcloud;

import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(ConfigServerApplication.class)
                .web(WebApplicationType.SERVLET)
                .run(args);
    }
}

5.application.yaml配置文件

image.png image.png

6.启动ConfigServerApplication

image.png

7.发送请求及返回值

image.png
image.png

8.会存到本地

image.png

9.不同请求(不同的格式)

image.png

![]O]YUX[1$R9U%}SO3U}Y{G.png

image.png

10.通配符格式

image.png

相关文章

网友评论

      本文标题:6.搭建配置中心Config-Server

      本文链接:https://www.haomeiwen.com/subject/kbjztktx.html