springCloud -- config的初步使用

 

1 springcloud-config服務端的初步配置java

<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>

 

server: 
  port: 3344 
  
spring:
  application:
    name:  springcloud-config
  cloud:
    config:
      server:
        git:
          uri: https://github.com/xiaoshi1994/springCloud-config.git   #GitHub上面的git倉庫名字
          username: 用戶名
          password: 密碼

 

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的部分命令git

#下載項目到本地
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
相關文章
相關標籤/搜索