spring 云配置启动时克隆 http.postBuffer 问题

spring cloud config clone-on-start http.postBuffer issue

我在使用 bitbucket url 启动 spring 云配置服务器时遇到问题 Integer value http.postbuffer out of range

application.yml

server:
    port: 8888

spring:
    application:
        name: CONFIGSERVER
    cloud:
     config:
        label: master
        server:
          git:
            clone-on-start: true
            uri: https://bitbucket.org/MyGitRepo/config_server_env_profiles.git
            username: <username>
            password: <password>

堆栈跟踪

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path
 resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is
 java.lang.IllegalArgumentException: Integer value http.postbuffer out of range
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=13=](AbstractBeanFactory.java:317)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1325)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1291)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPost
Processor.java:659)
        ... 96 more
Caused by: java.lang.IllegalArgumentException: Integer value http.postbuffer out of range
        at org.eclipse.jgit.lib.Config.getInt(Config.java:230)
        at org.eclipse.jgit.lib.Config.getInt(Config.java:209)
        at org.eclipse.jgit.transport.TransportHttp$HttpConfig.<init>(TransportHttp.java:247)
        at org.eclipse.jgit.transport.TransportHttp.parse(TransportHttp.java:237)
        at org.eclipse.jgit.transport.TransportHttp.parse(TransportHttp.java:234)
        at org.eclipse.jgit.lib.Config.get(Config.java:703)
        at org.eclipse.jgit.transport.TransportHttp.<init>(TransportHttp.java:282)
        at org.eclipse.jgit.transport.TransportHttp.open(TransportHttp.java:190)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:566)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:443)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:324)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:293)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:225)
        at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:293)
        at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:190)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:433)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.initClonedRepository(JGitEnvironmentRepository.java:249)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:182)
        at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.
java:68)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1761
)

可能是什么问题和解决方案?

显然,在克隆时 org.eclipse.jgit 库使用系统配置的属性,其中之一 属性 是 http.postBuffer .

它尝试将值转换为整数,如果值太大(或太小)则失败并出现超出范围的错误。

我通过 $ git config --get http.postBuffer 验证了 属性,它返回值 4572864000

我在 .gitconfig 文件中验证,它是全局值,所以我将值降低为 524288000

然后它就像魅力一样奏效。希望对面临同样问题的人有所帮助。

对我来说有用的是将全局配置设置为 1MB:

git config --global http.postBuffer 1024