配置目的:SpringCloud config通过Gitee获取配置信息
配置步骤:
hosts文件配置127.0.0.1 config-3344.com
1. 在gitee上创建新仓库和3个文件
2. 创建3344模块
5. 导包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
注意:这里一定要注意版本,不然后面很容易报错!!!!!
6. 写配置
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: https://gitee.com/huanggang0507/springcloud-config.git #GitHub上面的git仓库名字
####搜索目录
search-paths:
- springcloud-config
username: your username
password: your password
####读取分支
label: master
#服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
7. 主程序类
@SpringBootApplication
@EnableConfigServer
public class MainAppConfigCenter3344 {
public static void main(String[] args) {
SpringApplication.run(MainAppConfigCenter3344.class, args);
}
}
8. 业务类
无
9. 测试
输入http://config-3344.com:3344/master/config-test.yml
即可访问gitee上test文件。