我们将现有的Spring Web应用程序部署为Amazon Elastic Beanstalk中的WAR文件.目前,我们将属性文件作为http资源加载,以便为我们提供单一的属性占位符配置解析源.我正在调查用新的Spring云配置服务器替换它,以便为我们提供git版本控制等的好处.
但是文档(http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html)似乎只描述了一个Spring Boot客户端应用程序.是否可以在现有的Web应用程序中设置Spring Cloud Config Client?我是否需要手动设置Bootstrap父应用程序上下文等 - 这是否有任何示例?我们当前的spring配置是基于XML的.
我刚刚进入spring-cloud-config,我正在研究这个基础项目.我想知道是否可能以及如何重写此客户端以不使用Spring Boot.
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@EnableAutoConfiguration
@ComponentScan
@RestController
@RefreshScope
public class ClientApp {
@Value("${bar:World!}")
String bar;
@RequestMapping("/")
String hello() {
return "Hello " + bar + "!";
}
public static void main(String[] args) {
SpringApplication.run(ClientApp.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
这样做的原因是我们正在考虑在我们的Spring批量Web服务中使用spring-cloud-config,但是我们使用旧的spring和xmls,而不是spring boot.我找不到任何与此相关的文档.