增加 spring cloud config 整合用例
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
package com.heibaiying.configserver;
|
||||
|
||||
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 ConfigServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
server:
|
||||
port: 8020
|
||||
# 指定注册中心地址
|
||||
eureka:
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://localhost:8010/eureka/
|
||||
# 指定服务命名
|
||||
spring:
|
||||
application:
|
||||
name: config-server
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
git:
|
||||
uri: https://github.com/heibaiying/spring-samples-for-all/
|
||||
search-paths: spring-cloud/spring-cloud-test-config/
|
||||
# 如果代码仓库是公开的 则 不需要设置用户名和密码
|
||||
username:
|
||||
password:
|
||||
# 指定拉取的配置文件的存放的位置,配置文件最后存储的目录为 basedir + search-paths
|
||||
# 这个地方还需要注意的是,配置文件的仓库最好只放配置文件
|
||||
# 因为配置中心不仅会拉取search-paths下的文件,还会把uri指定仓库中的全部文件拉取到basedir下
|
||||
basedir: D:\git-config
|
||||
# 指定分支
|
||||
label: master
|
@ -0,0 +1,17 @@
|
||||
package com.heibaiying.configserver;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ConfigServerApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user