我查看了spring-cloud-config client without Spring Boot和许多其他内容,但没有找到令人信服的答案。因此,这里再次出现:

问题:
在Spring应用程序中,是否可以在没有Spring Boot的自动配置的情况下使用Spring Cloud Config服务器/客户端?使用Spring Boot是使用这些框架的要求吗?

如果是:

  • 是否有任何文档清楚地描述了在没有Spring Boot的情况下启用Spring Cloud Config服务器/客户端需要做什么?
  • 是否有任何示例项目清楚地描述了在没有Spring Boot的情况下启用Spring Cloud Config服务器/客户端需要做什么?
  • 最佳答案

    我不知道文档或示例项目。但是,我们正在我们的项目中做到这一点。

    假设您正在使用PropertySourcesPlaceholderConfigurer,则只需将配置服务器URI作为属性源包括在内:

    <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命令行,就像您可能需要通过引导来完成一样。

    关于spring - 没有Spring Boot的Spring Cloud Config Server,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35572457/

    10-11 22:27
    查看更多