说明
我们现在使用spring cloud config 远程连接github会存在网络跟不上问题,以及本地git密钥问题。
1.github更改了密钥策略原来生成的rsa会导致报错,需要使用命令重新生成ed25519密钥
2.配置需要按照上述配置
force-pull: true #这个参数不加可能会有网络导致连接不上
案例
将工程注册到eureka,需要自助构建项目。
1.新建工程cloud-config-center-3344
2.pom文件
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
3.yml(github)
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: https://github.com/****/springcloud2023.git #GitHub上面的git仓库名字
# username: account #私有仓库才需要账号密码
# password: password
search-paths: ####搜索目录
- springcloud-config
force-pull: true #
# ignore-local-ssh-settings: true
skip-ssl-validation: true
####读取分支
label: main
#服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
3.yml(gitee)
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: git@gitee.com:/***.git #GitHub上面的git仓库名字
username: 你的账号 #(开源不需要)私有仓库才需要账号密码
password: 密码
search-paths: ####搜索目录
- 20.springcloud-config
force-pull: true #
ignore-local-ssh-settings: true
skip-ssl-validation: true
private-key: |
-----BEGIN RSA PRIVATE KEY-----
你的.ssh目录下id_rsa内容=
-----END RSA PRIVATE KEY-----
default-label: dev
####读取分支
label: dev
#服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
4.测试
本地浏览器访问:http://localhost:3344/main/config-dev.yml