没有 Spring Boot 的 Spring Cloud Config Server [英] Spring Cloud Config Server without Spring Boot
问题描述
我看过没有Spring Boot的spring-cloud-config客户端 和许多其他人,还没有找到令人信服的答案.所以又来了:
I have looked at spring-cloud-config client without Spring Boot and many others and have not found a convincing answer. So here it goes again:
问题:在 Spring 应用程序中,是否可以在没有 Spring Boot 的自动配置的情况下使用 Spring Cloud Config 服务器/客户端?使用 Spring Boot 是使用这些框架的必要条件吗?
Question: Is it possible, in a Spring app, to use Spring Cloud Config server/client without the automagic configuration of Spring Boot? Is using Spring Boot a requirement for using these frameworks?
如果是:
- 是否有任何文档清楚地描述了在没有 Spring Boot 的情况下启用 Spring Cloud Config 服务器/客户端需要做什么?
- 是否有任何示例项目清楚地描述了在没有 Spring Boot 的情况下启用 Spring Cloud Config 服务器/客户端需要做什么?
推荐答案
我不知道文档或示例项目.然而,我们正在我们的项目中这样做.
I'm not aware of documentation or a sample project. However we are doing it in our projects.
假设您使用的是 PropertySourcesPlaceholderConfigurer,您只需要包含配置服务器 URI 作为属性源:
You just need to include the configuration server URI as a property source, assuming you are using PropertySourcesPlaceholderConfigurer:
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" id="propertyPlaceholder">
<property name="locations">
<list>
<value>http://your-config-server.com:8888/application-${spring.profiles.active}.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="false"/>
</bean>
您必须确保将 -Dspring.profiles.active=current_profile 传递给 java 命令行,就像您可能在启动时所做的那样.
You have to make sure to pass -Dspring.profiles.active=current_profile to the java command line, like you probably would have done with boot.
这篇关于没有 Spring Boot 的 Spring Cloud Config Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!