当前位置: 首页 > 知识库问答 >
问题:

将Spring云配置服务器连接到本地git存储库失败

熊朝
2023-03-14

当我击球时http://localhost:8888/limits-服务/默认设置:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Apr 27 16:40:38 IST 2020
There was an unexpected error (type=Internal Server Error, status=500).
Cannot load environment
java.lang.IllegalStateException: Cannot load environment
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:299)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.getLocations(JGitEnvironmentRepository.java:246)
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.getLocations(MultipleJGitEnvironmentRepository.java:146)
    at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:57)
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:187)
    at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:58)
    at org.springframework.cloud.config.server.environment.EnvironmentEncryptorEnvironmentRepository.findOne(EnvironmentEncryptorEnvironmentRepository.java:61)
    at org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:136)
    at org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
    at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:499)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at org.springframework.cloud.config.server.environment.EnvironmentController$$EnhancerBySpringCGLIB$$61a7f28e.defaultLabel(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: No directory at file:///C:lenovo G50git-localconfig-repo/limits-service.properties
    at org.springframework.util.Assert.state(Assert.java:73)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyFromLocalRepository(JGitEnvironmentRepository.java:576)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:561)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.createGitClient(JGitEnvironmentRepository.java:547)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:268)
    ... 72 more

这是我的应用程序属性文件:

spring.application.name=spring-cloud-config-server
server.port=8888
spring.cloud.config.server.git.uri=file:///C:\lenovo G50\git-localconfig-repo/limits-service.properties

这是我的本地git回购文件:

limits-service.minimum=8
limits-service.maximum=888

这是我的主要课程:

package com.in28minutes.microservices.springcloudconfigserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@EnableConfigServer
@SpringBootApplication
public class SpringCloudConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringCloudConfigServerApplication.class, args);
    }
}

请帮我解决这个问题。

共有3个答案

岳承悦
2023-03-14

同时删除位置路径中的所有反斜杠,并将其替换为正斜杠。始终记住在位置路径之前使用file://

例如:文件://C:/用户/谷歌/桌面/SpringLearning/Mocroservice_new_June/git-localconfig-repo

像这样试试

司马狐若
2023-03-14

堆栈跟踪中的最后一个条目显示了无效的资源位置。

java.lang.IllegalStateException:无目录位于file:///C:lenovoG50git localconfig报告/限制service.properties

因为这是在JVM中运行的,所以不需要在路径中使用反斜杠。在这种情况下,反斜杠用于转义紧跟在斜杠后面的字符。将反斜杠改为正斜杠,这样应该可以避免这个错误。这与配置服务器的启动和运行没有直接关系,所以不能保证这会解决所有的问题。

此外,最好将堆栈跟踪格式化为代码,使其对其他用户更具可读性。

周和歌
2023-03-14

替换application.properties:

spring.cloud.config.server.git.uri=file:///C:\lenovo G50\git-localconfig-repo/limits-service.properties

spring.cloud.config.server.git.uri=file://C:/lenovo G50/git-localconfig-repo
 类似资料:
  • -在我的本地f:\git-local-repository\repository上创建了git repository文件夹 -使用类路径链接源链接它-为我的服务添加属性文件 -在提交位置f:\git-local-repository\repository上的更改后 预期结果:将显示应用程序属性详细信息和其他URL的

  • 我在连接到存储配置的存储库时,在Spring云配置服务器(Spring引导)日志中看到问题。我不确定它是否由于凭据或其他原因而无法克隆(不允许git-upload-pack)。任何指向此的指针都将很棒。 配置服务器应用程序的Spring启动应用程序属性如下所示 - endpoint返回以下响应:

  • Spring云配置框架: 我正在尝试将java项目中的SpringCloud配置与后端存储库git(即bitbucket)集成。基本上,我在不同的场合更频繁地遇到两个错误。 在上述情况下,它使用缓存版本和tomcat/undertow服务器启动,没有任何问题。 Git版本: git版本2.24。0 错误1:git-上传-包 2020-04-11 00:00:20-克隆到基目录时发生WARN错误。

  • 关于上面的问题,我想请您帮忙。现在我正在尝试将应用程序(SpringCloudConfigServer)与另一个应用程序(limit-service)连接,limit-service应用程序必须选择SpringCloudConfigServer属性文件。当我点击http://localhost:8080/limits时,我需要像{“maximum”:888,“minimum”:8}一样获得oupp

  • 我正在使用GIT在Spring云配置服务器上执行POC。 Spring Boot1.5.3.RELEASEJava1.8 Spring Tool Suitehttps://github.com/kishornpatil/ 我已经在网络连接中正确设置了STS代理。 我有 我得到以下例外,当我请求 2017-05-18 11:11:15.714错误9608--[nio-888-exec-4]o.a.c

  • 我们正在配置spring云配置服务器,下面是我的应用程序属性的外观: 我可以登录到github url,即https://github.com/myorganization/config-store.git使用用户名MyUser和密码MyPassword作为上述属性,但当我试图启动我的配置服务器使用:./mvnw sping-boot: run我得到以下错误: 我已经尝试了很多东西,但现在没有任何