新建一个config Server模块;
引入如下依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-consul-discovery</artifactId> </dependency> <dependency> <groupId>org.tmatesoft.svnkit</groupId> <artifactId>svnkit</artifactId> </dependency>//这个很重要,配置svn必须要这个 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>${snakeyaml.version}</version> </dependency>//关于yaml文件的一些格式方面的东西
配置application.yml
server: port: 8666 spring: profiles: active: subversion #这里一定要,不然会默认为git方式 application: name: config-server cloud: consul: host: localhost port: 8500 discovery: service-name: config-server config: server: svn: uri: svn://182.254.174.181/tzg_backend_src/trunk search-paths: "{application}" #按应用名搜索问文件夹 default-label: tzg-configs #默认目录 username: xxx password: xxx
启动项目,访问:http://localhost:8666/demomirco/env;http://localhost:8666/demomirco/dev;
特别注意!!!上传到svn的文件一定要UTF-8模式,否则读不出来!!!(这个原理其实是从svn吧配置文件缓存到本地,如果svn上有改动会缓存一份新的下来)踩了大半天的坑,太不容易了