Spring Cloud Config uses github or gitee connection

Source: Internet
Author: User
Tags begin rsa private key

1. Create the Springcloud project, and introduce the corresponding spring-config-server corresponding 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 ></version>        </dependency>        <dependency>            <groupId> org.springframework.boot</groupid>            <artifactId>spring-boot-actuator</artifactId>        </dependency>

2. Create a Spring Boot startup class:

Add the following two annotations

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 pm 7:58 */@EnableConfigServer @springbootapplicationpublic Class Configserverapplication {public    static void Main (string[] args) {        Springapplication.run ( Configserverapplication.class,args);}    }


3. Add Application.yml

Because there are two types of connection git: one for the common No access password, a use of account password login, one with SSH login,

(i). Completely public, no password access configuration:

Server:  port:3344 #设置端口spring:  application:    name:config-server #设置名称  Cloud:    config:      Server:        git:          uri: [email protected]:lonecloud/xxx.git #设置git仓库地址          force-pull:true #设置强行pull拉取

(b). Login with account password access

Server:  port:3344 #设置端口spring:  application:    name:config-server #设置名称  Cloud:    config:      server:        git:          uri: [email protected]:lonecloud/xxx.git #设置git仓库地址          force-pull:true #设置强行pull拉取          username:lonecloud          Password:  password #填写你自己密码

(c). SSH login with no password, the most pit is the third, if your host is configured with SSH directly with (a) scheme, if not configured, you need to generate the corresponding SSH key, copy it here, access to both

Server:  port:3344spring:  application:    name:config-server  Cloud:    config:      server:        git:          uri: [email protected]:lonecloud/xxx.git          ignorelocalsshsettings:true          force-pull:true          Privatekey: |   #这个地方复制你的RSA密码, remember there's a | Don't forget                      -----BEGIN RSA private key-----                                            -----END RSA private Key-----


4. Direct access to this address, because my configuration address is 3344 port, so my address is http://localhost:3344/application-dev.yml

The following parameter is {The file name on your git}-{profile}.yml

Profile, which is the configuration file category you set in your profile, for your dev or test environment

There is a problem welcome to join the group: 416052025. Communication

Spring Cloud Config uses github or gitee connection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.