Eclipse를 통해 Maven 웹 프로젝트에서 작업하고 있습니다. web.xml
에는 Maven을 실행할 때 사용하는 프로필에 따라 값을 변경해야하는 context-param이 있습니다.Maven : web.xml 파일에서 변수를 채우는 방법
<project>
<profiles>
<profile>
<id>prod</id>
<properties>
<ambiente.producao>true</ambiente.producao>
</properties>
</profile>
<profile>
<id>desenv</id>
<properties>
<ambiente.producao>false</ambiente.producao>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/webapp/WEB-INF/</directory>
<filtering>true</filtering>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
내가 인터넷에서 발견 된 참조에 따라 플러그인을 받는다는 전쟁 - 플러그인으로 모두 resources
태그를 사용하고 있습니다 : 나는 다음과 같은 구성이 프로젝트의 POM 파일에서
<context-param>
<param-name>producao</param-name>
<param-value>${ambiente.producao}</param-value>
</context-param>
. 그러나 예상대로 작동하지 않았습니다. 이클립스에서는 목표가
인 maven을 실행하여을 새로 설치하고 "프로파일"로
을 또는
을 지정하고으로 꾸밉니다. Maven을 실행 한 후
web.xml
에서
${ambiente.producao}
속성이 대체되지 않는다는 것을 알았습니다. 따라서 내가 뭘 잘못했는지 알고 싶습니다. 필터링 리소스 또는 maven-war-plugin 만 사용해야합니까?
감사합니다,
라파엘 아폰소는
이것은 아주 적당하고 합리적인 접근 및 설명이다. 감사! –
이것은 마술 열쇠였습니다 : "filteringDeploymentDescriptors> true filteringDeploymentDescriptors>" –