【发布时间】:2018-11-14 09:43:37
【问题描述】:
我有 1 个弹簧启动应用程序。在此应用程序中,我已将 1 个电子商务系统配置为弹性路径(在 application.properties 文件中配置弹性路径的端点 url)。现在我必须将我的 Spring Boot 应用程序提供给其他一些人。它将部署在tomcat服务器上。我不想给出源代码。所以我可以制作战争文件,但现在的问题是他们有自己的弹性路径电子商务,他们想要配置自己的电子商务。
我想外部化一些将覆盖现有属性的属性。
我的 springboot 应用程序有 2 个模块: 1) 具有 elasticpath-application.properties 的弹性路径模块 2)salesforce-salesforce-application.properties
现在我必须外部化“C:\apache-tomcat-8.5.29\conf\ep-external.properties”文件,该文件将覆盖现有属性。现在的问题是 @PropertySource 正在加载到最后一个位置。所以我的外部文件无法覆盖该属性。
@SpringBootApplication
@PropertySource(value = {"classpath:application.properties", "classpath:elasticpath-application.properties", "classpath:salesforce-application.properties")
public class SpringBootDemo extends SpringBootServletInitializer implements CommandLineRunner {
private static final Logger LOG = LoggerFactory.getLogger(SpringBootDemo.class);
private ServletContext servletContext;
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//application = application.properties("file:C:\\apache-tomcat-8.5.29\\conf\\ep-external.properties");
return application.sources(SpringBootDemo.class);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
this.servletContext = servletContext;
super.onStartup(servletContext);
}
public static void main(String[] args) {
SpringApplication.run(SpringBootDemo.class, args);
}
@Override
public void run(String... args) throws Exception {
}
}
【问题讨论】:
标签: spring spring-boot