gpt4 book ai didi

git - 如何通过Docker Compose中的env vars为Jhipster Registry设置Spring Cloud Server的Git URI?

转载 作者:行者123 更新时间:2023-12-02 19:30:25 25 4
gpt4 key购买 nike

Jhipster Registry page上,提到我们可以通过以下参数为Spring Cloud Config设置Git存储库。

--spring.profiles.active=prod --spring.security.user.password=admin --jhipster.security.authentication.jwt.secret=secret-key --spring.cloud.config.server.composite=https://github.com/jhipster/jhipster-registry-sample-config --spring.cloud.config.server.composite[0].type=git --spring.cloud.config.server.composite[0].uri=https://github.com/jhipster/jhipster-registry-sample-config

但是我想通过docker-compose中的环境变量设置这些参数,如何实现呢?特别是这个:带有方括号的spring.cloud.config.server.composite [0] .uri。

更新资料

我尝试了GaëlMarziou的答案中定义的拼写,但是没有用。
这是我使用的docker jhipster-registry.yml,它是通过jhipster docker-compose子生成器生成的,在其中添加了Spring Cloud Config
version: '2'
services:
jhipster-registry:
image: jhipster/jhipster-registry
environment:
- SPRING_PROFILES_ACTIVE=prod,git
- SPRING_SECURITY_USER_PASSWORD=admin
- JHIPSTER_REGISTRY_PASSWORD=admin
- JHIPSTER_LOGGING_LOGSTASH_ENABLED=true
- JHIPSTER_LOGGING_LOGSTASH_HOST=jhipster-logstash
- JHIPSTER_METRICS_LOGS_ENABLED=true
- JHIPSTER_METRICS_LOGS_REPORTFREQUENCY=60
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE=https://github.com/anthonyrichir/demo-feign-config
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/anthonyrichir/demo-feign-config
ports:
- 8761:8761

使用此配置,注册表会显示:
Failed to bind properties under 'spring.cloud.config.server.composite' to java.util.List<java.util.Map<java.lang.String, java.lang.Object>>:

Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.List<java.util.Map<java.lang.String, java.lang.Object>>]

我也尝试了这种配置:
version: '2'
services:
jhipster-registry:
image: jhipster/jhipster-registry
environment:
- SPRING_PROFILES_ACTIVE=prod,git
- SPRING_SECURITY_USER_PASSWORD=admin
- JHIPSTER_REGISTRY_PASSWORD=admin
- JHIPSTER_LOGGING_LOGSTASH_ENABLED=true
- JHIPSTER_LOGGING_LOGSTASH_HOST=jhipster-logstash
- JHIPSTER_METRICS_LOGS_ENABLED=true
- JHIPSTER_METRICS_LOGS_REPORTFREQUENCY=60
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/anthonyrichir/demo-feign-config
ports:
- 8761:8761

我收到此错误:
Caused by: java.lang.IllegalStateException: You need to configure a uri for the git repository
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:245)
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:69)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)
... 88 common frames omitted

最佳答案

spring.cloud.config.server.composite[0].uri属性应映射到SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI环境变量。

参见https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-relaxed-binding

关于git - 如何通过Docker Compose中的env vars为Jhipster Registry设置Spring Cloud Server的Git URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51884749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com