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
一.分布式系统面临的--配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的力度相对较小,因此系统中会出现大量的服务.由于每个服务都需要必要的配置信息才能运行,所以一套集中式的.动 ...
随机推荐
- java中的定时任务小示例
package package_1; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Timer; ...
- Java 简单的登录验证码
1 验证码的作用 验证码是为了区分人与机器,如果没有验证码机制,web网站或者应用会遇到很多问题,具体如下: ① 网站容易被暴力登录攻破密码,可以制作一个自动程序不断的尝试登录,密码很容易被破解,系统 ...
- maven eclipse 第3方包
C:\Users\3510\.m2\repository\myjar install:install-file -Dfile=C:\Users\3510\.m2\repository\myjar\al ...
- [转帖]web安全:通俗易懂,以实例讲述破解网站的原理及如何进行防护!如何让网站变得更安全。
web安全:通俗易懂,以实例讲述破解网站的原理及如何进行防护!如何让网站变得更安全. https://www.cnblogs.com/1996V/p/7458377.html 感谢原作者写的内容 安全 ...
- Mybatis 配置resultMap一对多关联映射
resultMap配置: 引用: PO类: 接口: 测试: public class UserMapperTest { private SqlSessionFactory sqlSessionFact ...
- 基于vue-cli,sass,vant的移动端项目
项目架构 开始 vue init webpack 项目名称 //新建项目,cd进入新项目 npm install axios //先安装! ...
- 使用npm安装一些包失败了,更换npm源
镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 1.通过config命令 npm config set registry https://regist ...
- IIS下载地址
https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=1038
- eclipse 编码
单个修改 右击 选择properties
- Android常用的技术框架与博客社区
技术框架 图片加载 Glide Fresco Volley Picasso Universal Image Loader 网络请求 okhttp retrofit Volley android-asy ...