Spring Cloud Config分布式配置中心的使用和遇到的坑

1、springboot: Finchley.RC2 Cannot load environment] with root cause

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1967) ~[na:1.8.0_131]
	at org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.lookupHttpClientBuilder(HttpClientConfigurableHttpConnectionFactory.java:69) ~[spring-cloud-config-server-2.0.0.RC2.jar:2.0.0.RC2]
	at org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.create(HttpClientConfigurableHttpConnectionFactory.java:56) ~[spring-cloud-config-server-2.0.0.RC2.jar:2.0.0.RC2]
	at org.eclipse.jgit.transport.TransportHttp.httpOpen(TransportHttp.java:830) ~[org.eclipse.jgit-4.11.0.201803080745-r.jar:4.11.0.201803080745-r]
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:491) ~[org.eclipse.jgit-4.11.0.201803080745-r.jar:4.11.0.201803080745-r]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.31.jar:8.5.31]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158) ~[spring-boot-actuator-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126) ~[spring-boot-actuator-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at 
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.31.jar:8.5.31]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

**解决方法:**是Finchley.RC2版本问题,改成Finchley.RC1即可。

##2、SpringCloud Config配置远程git仓库获取配置,一直报Cannot clone or checkout repository

解决方法:

将配置,注意uri地址

spring.cloud.config.label=master
spring.cloud.config.server.git.uri=https://github.com/xxx/SpringCloud.git
spring.cloud.config.server.git.search-paths=application

改成这种格式

spring.cloud.config.label=master
[email protected]:xxx/SpringCloud.git
spring.cloud.config.server.git.search-paths=application

你可能感兴趣的:(Spring)