2017-11-17 7 views
1

에서 자바 시스템 속성 및 환경 변수를 제외 여기 설명 : https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.htmlSpringBoot의 재산 해상도에 관한 SpringBoot 구성

내가 메커니즘에서 제외 할 : 가능

9. Java System properties (System.getProperties()). 
10. OS environment variables. 

인가? 당신의 봄 부팅 응용 프로그램을 인스턴스화 할 때

감사

+0

원하는 이유가 무엇입니까? 문맥을 이해하기 위해서 – pvpkiran

답변

1

당신은 StandardEnvironment의 자신의 구현을 제공 할 수 있습니다. 예를 들어

:

public static void main(String[] args) { 
    SpringApplicationBuilder applicationBuilder = new SpringApplicationBuilder(Application.class) 
      .environment(new StandardEnvironment(){ 
       @Override 
       protected void customizePropertySources(MutablePropertySources propertySources) { 
        // do not add system or env properties to the set of property sources 
       } 
      }); 
    applicationBuilder.run(args); 
} 

또는 대안 :

public static void main(String[] args) { 
    SpringApplicationBuilder applicationBuilder = new SpringApplicationBuilder(Application.class) 
      .environment(new StandardEnvironment(){ 
       @Override 
       public Map<String, Object> getSystemEnvironment() { 
        return new HashMap<>(); 
       } 

       @Override 
       public Map<String, Object> getSystemProperties() { 
        return new HashMap<>(); 
       } 
      }); 
    applicationBuilder.run(args); 
} 

어느 쪽이든, 당신은 당신의 응용 프로그램의 특성은 어떤 시스템이나 환경 속성을 포함하지 않도록.