2017-11-17 12 views
0

세 가지 프로젝트가 있습니다. Proj 3은 Proj 2에 의존하고 Proj 2는 Proj 1에 종속됩니다. 각 프로젝트는 Spring Boot를 사용하고 yml 파일로 구성됩니다. Proj 2에서 Proj 1의 yml 구성을 반복하고 싶지 않습니다. 마찬가지로 Proj 2에서 Proj 2와 Proj 1의 yml 구성을 반복하고 싶지 않습니다.yml 구성 파일 소품을 반복하지 않고 Spring에서 다중 모듈 프로젝트를 구성하는 방법은 무엇입니까?

어떻게이 작업을 수행 할 수 있습니까? 내가 아는 한, 세 개의 프로젝트에서 하나의 파일 (사용 중) 만 가질 수 있습니다.

+0

해결책이 있지만 application.properties 파일입니다. 그것을 원하니? –

답변

0

내 .properties를 .yml로 변경하려고했는데 나에게 적합하다.

@Configuration 
public class AppConfig { 

    @Profile("staging") 
    @Bean 
    public static PropertySourcesPlaceholderConfigurer properties() { 
     PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); 
     YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean(); 
     yaml.setResources(new ClassPathResource("common-staging.yml")); 
     propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject()); 
     return propertySourcesPlaceholderConfigurer; 
    } 
} 
+0

고맙지 만 이미 속성 파일을 사용하여이 작업을 수행하는 방법을 알고 있습니다. yml 파일을 사용해야합니다. – James

+0

내 대답을 편집했습니다. –