Maven 3.0.3을 사용하고 있습니다. 스크립트 ("env")에 변수를 정의해야합니다. 나는 아무도가 "-P"로 지정되어 있지 않은 경우에만 프로필을 활성화 어떻게 내가 <profile>
요소마다 변수를 정의하는 내 치어의 <profiles>
섹션 ... 내 pom.xml 파일에서기본적으로 프로필 활성화
<profile>
<id>qa</id>
<properties>
<env>qa</env>
...
</properties>
</profile>
을 가지고 명령 줄 옵션 (그리고 정의되지 않은 경우 변수를 설정)? 내가 설정 한 집행자 플러그인은 내가 "ENV"변수의 정의가 필요하기 때문에
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<properties>
<url>http://localhost:8080/manager</url>
<server>nnadbmon-dev-tomcat</server>
</properties>
</profile>
하지만 명령 "MVN 컴파일"실행이 실패, 아래 시도했다. 여기
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env</property>
<message>Environment missing. This should be either dev, qa, or prod, specified as part of the profile (pass this as a parameter after -P).</message>
<regex>^(dev|qa|production)$</regex>
<regexMessage>Incorrect environment. Expecting one of dev, qa, or prod.</regexMessage>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
당신이 원하는 것은 분명하지 않습니다. 'env'속성에 대한 기본값을 제공 하시겠습니까? – bmargulies
예, env 속성에 기본값을 제공하고 싶습니다. – Dave
귀하의 집행자 구성을 게시하십시오. 실제로 'env'속성을 정의하지 않았습니다. 이러한 속성이 존재하고 특정 값이있는 경우 실행할 프로필을 설정하면됩니다. 기본 env 속성을 다른 값으로 속성 요소에 추가 할 수 있습니다. – bmargulies