2017-03-13 3 views
0

개발자 중 한 명은 몇 달 전에 팀을 떠났으 며 짧은 시간에 KT를 완료 할 수 없었습니다. 자, 이제 저는 시작할 수없는 프로젝트를 가지고 있습니다. 물론 덜 사용되는 구성 요소이지만, 오늘날은 물론 비판적이되었습니다.프로필이있는 springboot을 시작하십시오.

그래서, 기본적으로는 봄 부팅 응용 프로그램입니다 그리고 이것은 우리의 pom.xml 설정에있는 것입니다 : 나는 응용 프로그램을 시작할 때

<build> 
    <sourceDirectory>src/main/java</sourceDirectory> 
    <testSourceDirectory>test/main/java</testSourceDirectory> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.0</version> 
      <configuration> 
       <source>${java-version}</source> 
       <target>${java-version}</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <id>assembly</id> <!-- this is used for inheritance merges --> 
        <phase>package</phase> <!-- bind to the packaging phase --> 
        <goals> 
         <goal>single</goal> 
        </goals> 
        <configuration> 
         <finalName> 
          reporting-${owner}-${env} 
         </finalName> 
         <descriptors> 
          <descriptor>reporting-assembly.xml</descriptor> 
         </descriptors> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<profiles> 
    <profile> 
     <id>local</id> 
     <activation> 
      <property> 
       <name>env</name> 
       <value>local</value> 
      </property> 
     </activation> 
     <properties> 
      <config.path>src/main/resources/config/${owner}/local</config.path> 
     </properties> 
    </profile> 
    <profile> 
     <id>qa</id> 
     <activation> 
      <property> 
       <name>env</name> 
       <value>qa</value> 
      </property> 
     </activation> 
     <properties> 
      <config.path>src/main/resources/config/${owner}/qa</config.path> 
     </properties> 
    </profile> 
    <profile> 
     <id>staging</id> 
     <activation> 
      <property> 
       <name>env</name> 
       <value>staging</value> 
      </property> 
     </activation> 
     <properties> 
      <config.path>src/main/resources/config/${owner}/staging</config.path> 
     </properties> 
    </profile> 
    <profile> 
     <id>prod</id> 
     <activation> 
      <property> 
       <name>env</name> 
       <value>prod</value> 
      </property> 
     </activation> 
     <properties> 
      <config.path>src/main/resources/config/${owner}/prod</config.path> 
     </properties> 
    </profile> 
</profiles> 

모든 config 폴더가 적절한 env.config 파일이 포함되어 있지만, 적절한 파일에 액세스 할 수 없습니다. 기본적으로 Run/Debug 구성에서 owner 및 env 속성을 설정할 위치를 알 수 없습니다. 내가 환경 변수 $ {ENV}와 $ {소유자} 난 아직 여기에 null 값을 받고 있어요 (디버그 구성에) 설정하더라도

:

public static <T> T loadJsonResourceIntoClass(String jsonResourcePath, Class<T> clazz) throws Exception { 
    URL jsonFilePathUrl = JsonUtil.class.getClassLoader().getResource(jsonResourcePath); 
    return objectMapper.readValue(jsonFilePathUrl != null ? jsonFilePathUrl.openStream() : null, clazz); 
} 

jsonFilePathUrl는 항상 null의

단서가 있습니까?

안드레아

+1

다음과 같은 환경 속성이 필요합니다 :'$ {env}'는 로컬 프로파일을 활성화하기 위해'local'으로 설정하고, qa 프로파일을 활성화시키기 위해'qa '로, 스테이징 프로파일을'staging'하고,'prod' 찌르다. 방금 ​​작성되었습니다. –

+0

아직도 작동하지 않습니다. - 질문을 업데이트했습니다. –

+1

mvn clean install -Plocal - Downer = 약간의 값이 질문은 스프링 프로파일이 아니라 Maven 프로파일에 관한 것입니다. –

답변

0

하게 IntelliJ IDEA에서 난 그냥 필요한 설정/{클라이언트}는 PHR에서 "자원"나보고 모듈 설정,이 경우 HC/지역 등/{환경} 폴더 지정 : 프로젝트 구조를 -> 모듈 -> YourApplicationName -> 소스 -> 자원을 선택하고 적절한 파일을 선택하십시오.

이클립스에서

같은이 실행 구성의 도움으로 수행 할 수 있습니다

생성, 관리 및 실행 구성 -> ClassYouWantToRun * -> 클래스 경로 -> 사용자 항목 -> 고급 -> 폴더를 추가하고 선택 구성 폴더.

또한 내 IDE에서 적절한 메이븐 프로파일을 활성화했습니다.