首页 文章

没有Spring Boot的Spring Cloud Config Server

提问于
浏览
5

我看过spring-cloud-config client without Spring Boot以及其他许多人并没有找到令人信服的答案 . 所以这里再说一遍:

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

如果是:

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

  • 是否有任何示例项目清楚地描述了为了在没有Spring Boot的情况下启用Spring Cloud Config服务器/客户端需要执行哪些操作?

1 回答

  • 3

    我不知道文档或示例项目 . 但是我们在我们的项目中这样做 .

    您只需要将配置服务器URI包含为属性源,假设您使用的是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命令行,就像您可能已经完成启动一样 .

相关问题