app配置中心服务器配置,配置中心搭建(spring-cloud-config-server)

1.github建立配置库

ed4bd7885f7f6bbe656d7ec49bf0f945.png

2.配置服务端

①建立项目

118c535c423eb23d881e095d49533741.png

②导入jar

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.cloud

spring-cloud-config-server

③yml配置java

server:

port: 8848

eureka:

client:

service-url:

defaultZone: http://localhost:7001/eureka

instance:

prefer-ip-address: true

spring:

application:

name: ruigou-config-server

cloud:

config:

server:

git:

uri: https://github.com/xxxxx/application_config.git

username: xxxxx

password: xxxxxxxx

④入口git

@SpringBootApplication

@EnableEurekaClient

@EnableConfigServer

public class ConfigServerApplication_8848 {

public static void main(String[] args) {

SpringApplication.run(ConfigServerApplication_8848.class);

}

}

⑤测试github

localhost:8848/application-plat-dev.ymlweb

3.配置客户端

Eureka,configserver不须要,其余的都是客户端

①建立项目spring

②导入jarspringboot

org.springframework.cloud

spring-cloud-starter-config

org.springframework.boot

spring-boot-maven-plugin

cn.rui97.ruigou.PlatApplication_8001

ZIP

repackage

③作配置服务器

spring:

profiles:

active: dev

cloud:

config:

name: application-plat #github上面名称

profile: ${spring.profiles.active} #环境 java -jar -D xxx jar

label: master #分支

discovery:

enabled: true #从eureka上面找配置服务

service-id: ruigou-config-server #指定服务名

#uri: http://127.0.0.1:1299 #配置服务器 单机配置

eureka: #eureka不能放到远程配置中

client:

service-url:

defaultZone: http://localhost:7001/eureka #告诉服务提供者要把服务注册到哪儿 #单机环境

instance:

prefer-ip-address: true #显示客户端真实ip

④打包测试app

ef8a98d2efb9acd88bf23be5e2d7c4d8.png

命令:java -jar -Dspring.profiles.active=test plat_services_8001-1.0-SNAPSHOT.jar

ca829f1337c9b03a0ea15e8e3a8bb108.png

84547c78e999960b9a63587b19a11ebb.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值