配置服务从码云上读取配置信息
1.在main()方法启动类上添加@EnableDiscoveryClient
和@EnableConfigServer
2.application.yml配置如下:
server:
port: 5900 #端口号
spring:
application:
name: wx-config-server #项目名
cloud:
config:
server:
git:
uri: https://gitee.com/keshuiji/spring-cloud-demo.git #properties属性文件的克隆下载路径
username: xxx #你在码云上登录的邮箱
password: xxxx #登录密码
search-paths: config-file #码云上的properties属性文件夹名
eureka:
client:
service-url:
defaultZone: http://root:111111@localhost:7000/eureka/
3.pom.xml配置如下,SpringCloud版本号是基于Dalston.SR4
<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.accp</groupId>
<artifactId>qq-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>qq-config-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.SR4</spring-cloud.version>
</properties>
<dependencies>
<!--server服务jar包-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
</project>
4.测试访问路径:IP:端口号/项目名/版本/分支名(默认是主分支master)
版本号有dev是开发版本和pro是运行版本和test测试版本