Mis*_*yed 6 spring spring-boot spring-cloud
我看过没有Spring Boot的spring-cloud-config客户端和许多其他客户端,并没有找到令人信服的答案.所以这里再说一遍:
问题:在Spring应用程序中,是否有可能在没有Spring Boot自动配置的情况下使用Spring Cloud Config服务器/客户端?使用Spring Boot是否需要使用这些框架?
如果是:
我不知道文档或示例项目。然而,我们正在我们的项目中这样做。
您只需包含配置服务器 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>
Run Code Online (Sandbox Code Playgroud)
您必须确保将 -Dspring.profiles.active=current_profile 传递到 java 命令行,就像您可能对 boot 所做的那样。
| 归档时间: |
|
| 查看次数: |
1611 次 |
| 最近记录: |