Spring cloud config 使用gitHub或者gitee连接
1. 创建SpringCloud项目,引入对应的Spring-config-server对应的jar
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>3.7.1.201504261725-r</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
2. 创建一个Spring boot启动类:
添加如下两个注解
@EnableConfigServer
@SpringBootApplication
package cn.lonecloud.config.server; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer; /**
* @author lonecloud
* @version v1.0
* @Package cn.lonecloud.config
* @Description: TODO
* @date 2018/6/12下午7:58
*/
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class,args);
}
}
3. 添加application.yml
由于连接git分两种:一种为共有没有访问权限密码的,一种使用账号密码登录,一种采用ssh登录,
(一).完全公开,无密码访问配置:
server:
port: 3344 #设置端口
spring:
application:
name: config-server #设置名称
cloud:
config:
server:
git:
uri: git@gitee.com:lonecloud/xxx.git #设置git仓库地址
force-pull: true #设置强行pull拉取
(二).采用账号密码访问登录
server:
port: 3344 #设置端口
spring:
application:
name: config-server #设置名称
cloud:
config:
server:
git:
uri: git@gitee.com:lonecloud/xxx.git #设置git仓库地址
force-pull: true #设置强行pull拉取
username: lonecloud
password: password #填写你自己密码
(三).采用SSH无密码登录,最坑的则是第三个,如果您的主机配置了ssh则直接采用(一)方案即可,如果没有配置则需要生成对应的ssh key,将其复制到此处,既可访问
server:
port: 3344
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: git@gitee.com:lonecloud/xxx.git
ignoreLocalSshSettings: true
force-pull: true
privateKey: | #这个地方复制你的RSA密码,记得这里有个| 别忘了
-----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
4. 直接访问该地址,由于我的配置地址为3344端口,所以我的地址为http://localhost:3344/application-dev.yml
后面的参数为{你的git上的文件名}-{profile}.yml
profile,这就是你在你的配置文件中设置的配置文件分类,用于分别你的事dev环境还是test环境
有问题欢迎加入群:416052025。交流
Spring cloud config 使用gitHub或者gitee连接的更多相关文章
- 跟我学SpringCloud | 第六篇:Spring Cloud Config Github配置中心
SpringCloud系列教程 | 第六篇:Spring Cloud Config Github配置中心 Springboot: 2.1.6.RELEASE SpringCloud: Greenwic ...
- 为Spring Cloud Config插上管理的翅膀
最近一致在更新Spring Cloud Config的相关内容,主要也是为这篇埋个伏笔,相信不少调研过Spring Cloud Config的用户都会吐槽它的管理能力太弱.因此,就有了下面为讲推荐的这 ...
- Spring Cloud Config采用数据库存储配置内容
在之前的<Spring Cloud构建微服务架构:分布式配置中心>一文中,我们介绍的Spring Cloud Server配置中心采用了Git的方式进行配置信息存储.这一设计巧妙的利用Gi ...
- Spring Cloud官方文档中文版-Spring Cloud Config(上)
官方文档地址为:http://cloud.spring.io/spring-cloud-static/Dalston.SR2/#spring-cloud-feign 文中例子我做了一些测试在:http ...
- Spring Cloud官方文档中文版-Spring Cloud Config(下)-客户端等
官方文档地址为:http://cloud.spring.io/spring-cloud-static/Dalston.SR2/#_serving_alternative_formats 文中例子我做了 ...
- SpringCloud(6)分布式配置中心Spring Cloud Config
1.Spring Cloud Config 简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组 ...
- Spring Cloud Config采用Git存储时两种常用的配置策略
由于Spring Cloud Config默认采用了Git存储,相信很多团队在使用Spring Cloud的配置中心时也会采用这样的策略.即便大家都使用了Git存储,可能还有各种不同的配置方式,本文就 ...
- Spring Cloud Config(配置中心)
每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code 一.简介 Spring Cloud Config为分布式系统中的外部配置提供服务器和客 ...
- 【八】Spring Cloud Config
一.分布式系统面临的--配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的力度相对较小,因此系统中会出现大量的服务.由于每个服务都需要必要的配置信息才能运行,所以一套集中式的.动 ...
随机推荐
- python3 常见的两种文件上传方法
1.上传页面带input type格式send_keys传值方式上传不能大于60k(具体看开发设置的value)文件大小 fx.find_element_by_id('xx').send_keys(r ...
- Day 5-6 反射和内置方法之item系列
python面向对象中的反射:通过字符串的形式操作对象相关的属性.python中的一切事物都是对象(都可以使用反射) #!_*_ coding:utf-8 _*_ class People: def ...
- 10分钟让你的代码更加pythonic
参考: https://blog.csdn.net/g8433373/article/details/80709116
- Object.defineProperties()与Proxy对象代理
Object.defineProperties() 了不起啊..vue.js通过它实现双向绑定的 Object.defineProperties(obj,props) 方法直接在一个对象上定义新的属性 ...
- Linux用户权限指令, 定时任务等指令
一. 网卡配置详解 网络配置文件: /etc/sysconfig/network 网络接口配置文件: /etc/sysconfig/network-scripts/ifcfg-INTERFACE_NA ...
- Ajax之Jquery封装使用举例
<html> <head> <meta charset="UTF-8"> <title>登陆页面</title> < ...
- Appium之开发环境搭建
1.下载Appium 去官方网站下载http://appium.io/# : 本次以appium-desktop-setup-1.8.0.exe 文件为例,使用桌面版就不再需要下载server版本: ...
- ES 6 系列 - 赋值的新方式:解构赋值
变量的解构赋值 es 6 允许按照一定的模式,从数组和对象中提取值,然后对变量进行赋值,这被称之为解构: 一.数组的解构赋值 最基本写法: let [a, b, c] = [1, 2, 3]; a / ...
- React 学习(六) ---- 父子组件之间的通信
当有多个组件需要共享状态的时候,这就需要把状态放到这些组件共有的父组件中,相应地,这些组件就变成了子组件,从而涉及到父子组件之间的通信.父组件通过props 给子组件传递数据,子组件则是通过调用父组件 ...
- JarvisOJ Basic veryeasyRSA
已知RSA公钥生成参数: p = 3487583947589437589237958723892346254777 q = 8767867843568934765983476584376578389 ...