개발자 중 한 명은 몇 달 전에 팀을 떠났으 며 짧은 시간에 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의
단서가 있습니까?
안드레아
다음과 같은 환경 속성이 필요합니다 :'$ {env}'는 로컬 프로파일을 활성화하기 위해'local'으로 설정하고, qa 프로파일을 활성화시키기 위해'qa '로, 스테이징 프로파일을'staging'하고,'prod' 찌르다. 방금 작성되었습니다. –
아직도 작동하지 않습니다. - 질문을 업데이트했습니다. –
mvn clean install -Plocal - Downer = 약간의 값이 질문은 스프링 프로파일이 아니라 Maven 프로파일에 관한 것입니다. –