四 建立SpringCloud_config服務專案,統一管理配置檔案
阿新 • • 發佈:2019-01-28
1,建立SpringCloud_config專案
2,匯入依賴pom
<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>
<groupId>com.shawmou.spring</groupId >
<artifactId>springCloud_config</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version >
</parent>
<!-- 匯入Spring Cloud的依賴管理 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId >
<version>Dalston.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- spring_config依賴 和 呼叫此服務的依賴不同 -->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 資原始檔拷貝外掛 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- java編譯外掛 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
3,講自己編寫的三個配置檔案傳遞到git中去
4,編寫配置檔案:application.yml
server:
port: 6688 #服務埠
spring:
application:
name: springcloud_config #指定服務名--->現在沒有用,後面講此服務註冊到eureka統一管理的時候,作為唯一識別符號
cloud:
config:
server:
git: #配置git倉庫地址
uri: https://github.com/shawemou/springcloudconfig.git