不读application.yml-Spring Boot自由部署为WAR

时间:2019-08-19 08:56:23

标签: spring spring-boot spring-boot-2

WEB-INF
 --application.yml (contains default properties)

External Folder custom-config 
  customNameConfig-DEV.yml 

在我的春季Boot应用程序类中:

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
//props=HashMap
props.put("spring.config.name","customNameConfig");
props.put("spring.config.location"."file:/custom-config/,classpath:/application.yml");
builder.properties(props).sources(MyAppliocation).web(WebApplicationType.Servlet);
}

它可以从

读取属性
  1. customNameConfig-DEV.yml放在外部(战争之外)

  2. 不检测application.yml之类的logging.config:file:/log4j2.json中的属性

spring.config.location”上的相同设置。“ file:/custom-config/,classpath:/application.yml”工作正常 当我运行时,它是 java -jar myapp.jar

到目前为止,我已经尝试过:

  1. "spring.config.location" = "file:/custom-config/,classpath:**/a**pplication.yml"

  2. "spring.config.location" = "file:/custom-config/,classpath:**a**pplication.yml"

  3. "spring.config.location" = "file:/custom-config/,classpath**:WEB**-INF/classes/application.yml"

  4. "spring.config.location" = "file:/custom-config/,classpath:**/W**EB-INF/classes/application.yml"

  5. "spring.config.additional-location" : "file::/custom-config/"

  6. "spring.config.location" = "classpath:/application.yml"

:(伤了我的头

应该怎么解决?

0 个答案:

没有答案