Spring Cloud入门教程-配置中心 Config,致Java高级工程师的一封信

4.0.0

com.springcloud.demo

springcloud-demo

1.0-SNAPSHOT

config-server

0.0.1-SNAPSHOT

jar

config-server

Demo project for Spring Boot

org.springframework.cloud

spring-cloud-config-server

org.springframework.boot

spring-boot-starter-test

test

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.boot

spring-boot-maven-plugin

在ConfigServerApplication 上添加注解 @EnableConfigServer 。

@EnableEurekaClient

@EnableConfigServer

@SpringBootApplication

public class ConfigServerApplication {

public static void main(String[] args) {

SpringApplication.run(ConfigServerApplication.class, args);

}

}

添加配置

server.port=8799

spring.application.name=config-server

#从本地读取配置文件####################################################

spring.profiles.active=native

spring.cloud.config.server.native.search-locations=classpath:/shared

#####################################################################

在resource 下创建文件夹shared,创建文件 config-client-dev.properties,并添加如下配置:

server.port=8700

application.name=config-server-v1

创建新Module config-client ,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”>

4.0.0

com.springcloud.demo

springcloud-demo

1.0-SNAPSHOT

config-client

0.0.1-SNAPSHOT

jar

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

config-client

Demo project for Spring Boot

org.springframework.boot

spring-boot-starter-web

org.springframework.cloud

spring-cloud-config-client

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值