Config:客户端连接服务器访问远程

springcloud-config: springcloud-config

push

pom

XML 复制代码
<?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>springcloud</artifactId>
        <groupId>com.kuang</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spring-config-client-3355</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <!--springcloud-config-server-->

<dependencies>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!--    完善监控信息    -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>
</project>
java 复制代码
package com.kuang.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConfigClientController {

    @Value("${spring.application.name}")
    private String applicationName;

    @Value("${eureka.client.service-url.defaultZone}")
    private String eurekaServer;
    @Value("${server.port}")
    private String port;

    @RequestMapping("/config")
    public String getConfig(){
        return "applicationName"+applicationName+
                "eurekaServer"+eurekaServer+
                "port"+port;
    }

}
XML 复制代码
#用户级别的配置
spring:
  application:
    name: springcloud-config-client-3355
XML 复制代码
#系统级别的配置
spring:
  cloud:
    config:
      uri: http://localhost:3344
      name: config-client #需要从git上读取的资源名称,不需要后缀
      profile: dev
      label: master
      # http://localhost:3344/config-client-dev/master
java 复制代码
package com.kuang.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ConfigClient_3355 {
    public static void main(String[] args) {
        SpringApplication.run(ConfigClient_3355.class,args);
    }
}
相关推荐
77tian4 分钟前
设计模式的原理及深入解析
java·开发语言·单例模式·设计模式·代理模式·享元模式·原型模式
RLG_星辰15 分钟前
SHELL练习题(1-11题)记录(牛客)
linux·运维·服务器·shell
国际云,接待21 分钟前
腾讯云怎么在游戏云中助力
服务器·游戏·云原生·重构·云计算·腾讯云
会飞的架狗师40 分钟前
【Spring Cloud Gateway】Nacos整合遇坑记:503 Service Unavailable
java·开发语言
重生之后端学习2 小时前
02-前端Web开发(JS+Vue+Ajax)
java·开发语言·前端·javascript·vue.js
✿ ༺ ོIT技术༻3 小时前
Linux:网络层的重要协议或技术
linux·服务器·网络
字节源流8 小时前
关于maven的依赖下不下来的问题
java·maven
pjx9878 小时前
服务间的“握手”:OpenFeign声明式调用与客户端负载均衡
java·运维·spring·负载均衡
prinrf('千寻)9 小时前
MyBatis-Plus 的 updateById 方法不更新 null 值属性的问题
java·开发语言·mybatis
老华带你飞9 小时前
实习记录小程序|基于SSM+Vue的实习记录小程序设计与实现(源码+数据库+文档)
java·数据库·spring boot·小程序·论文·毕设·实习记录小程序