条件:
首先需要在GitHub中创建配置中心仓库
org.springframework.cloud
spring-cloud-config-server
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
cn.kitey.spring
cloud-api-commons
${project.version}
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-devtools
runtime
true
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
注意新加入的config中的配置,其中的配置都是关于github中的信息
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务微服务名
cloud:
config:
server:
git:
skipSslValidation: true
uri: https://github.com/Kite-LY/springcloud-config #GitHub上面的git仓库名字
### 搜索目录
search-paths:
- springcloud-config
### 读取分支
label: master
#注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
package cn.kitey.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigCenterMain3344 {
public static void main(String[] args) {
SpringApplication.run(ConfigCenterMain3344.class, args);
}
}