Python 官方文档:入门教程 => 点击学习
目录spring-cloud Config Server的3种配置1.config 默认git加载2.加载本地开发环境3.加载 本地物理环境4.加载svn环境SpringCloud统
Spring-cloud Config Server 有多种种配置方式,今天我就在此介绍一下Git,local,svn三种配置方式,不过官方文档还是建议使用Git这种方式进行配置开发。
好的,现在开始!!!!!!!
通过spring.cloud.config.server.git.uri指定配置信息存储的git地址,比如:https://github.com/xxx/config-repo
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/config
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations= file:E:\\Java\\config
Http://localhost:8080/{application}/{profile}/{label},比如:http://localhost:8080/dmeo/development/trunk
### config server svn
spring.cloud.config.server.svn.uri=http://localhost:8080/dmeo/development/trunk
spring.cloud.config.server.svn.username=xxx
spring.cloud.config.server.svn.passWord=xxx
spring.profiles.active=subversion
PS: svn 环境 需要 引入 SVN jar包
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
1.配置不方便维护
2.配置内容的安全性和权限
3.更新配置项目需要重启
该项目即是eureka的客户端 又是Config的服务端
<?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>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zhu</groupId>
<artifactId>config</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>config</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</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>
yml配置
eureka:
client:
service-url:
defaultZone: http://localhost:8085/eureka/
server:
port: 8090
spring:
application:
name: config
cloud:
config:
server:
git:
uri: git@github.com:zhujin888/config-repo.git //git地址
username: git的账号
password: git的密码
主类:
package com.zhu.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigApplication.class, args);
}
}
一般存三份
dev
:开发test
:测试pro
:生产两种方式: 随便用哪一种
配置本地 git路径
eureka:
client:
service-url:
defaultZone: http://localhost:8085/eureka/
server:
port: 8090
spring:
application:
name: config
cloud:
config:
server:
git:
uri: git@github.com:zhujin888/config-repo.git
username:
password:
basedir: D:\My_Java\anli\gitconfig\basedir //配置本地git路径 把拉下来的配置文件存在这
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Spring-cloud Config Server的3种配置方式
本文链接: https://www.lsjlt.com/news/136651.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0