1 springcloud-config服务端的初步配置
代码语言:javascript复制<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.shi.springCloud04</groupId>
<artifactId>springCloud-04</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>springCloud04-config-3344</artifactId>
<dependencies>
<!-- springCloud Config -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<!-- 避免Config的Git插件报错:org/eclipse/jgit/api/TransportConfigCallback -->
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.10.0.201712302008-r</version>
</dependency>
<!-- 图形化监控 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 熔断 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</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-test</artifactId>
</dependency>
<!-- 热部署插件 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
</project>
代码语言:javascript复制server:
port: 3344
spring:
application:
name: springcloud-config
cloud:
config:
server:
git:
uri: https://github.com/xiaoshi1994/springCloud-config.git #GitHub上面的git仓库名字
username: 用户名
password: 密码
代码语言:javascript复制package com.shi.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer //开启配置中心服务端
public class SpringCloud_Config_3344 {
public static void main(String[] args) {
SpringApplication.run(SpringCloud_Config_3344.class, args);
}
}
Git的部分命令
代码语言:javascript复制#下载项目到本地
git clone git@github.com:xiaoshi1994/springCloud-config.git
# 查看当前项目的状态
git status
# 当前项目下面的全部信息
git add .
#提交到本地仓库
git commit -m "初始化配置文件"
# 把项目提交到远程仓库(如果提交不上去就“https://blog.csdn.net/kkkkkxiaofei/article/details/41483039”)
git push origin master