Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在POM中使用条件属性_Java_Spring_Maven - Fatal编程技术网

Java 如何在POM中使用条件属性

Java 如何在POM中使用条件属性,java,spring,maven,Java,Spring,Maven,我需要将所选的Maven概要文件传递给Spring,以便在使用Surefire插件运行回归测试时可以使用概要文件信息,方法是在下面添加argLine属性。所选配置文件的传递方式为: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin&

我需要将所选的Maven概要文件传递给Spring,以便在使用Surefire插件运行回归测试时可以使用概要文件信息,方法是在下面添加
argLine
属性。所选配置文件的传递方式为:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <argLine>-Dspring.profiles.active=@{spring.profiles.active} @{argLine}</argLine>
      </configuration>
    </plugin>
  </plugins>
</build> 

org.apache.maven.plugins
maven surefire插件
-Dspring.profiles.active=@{spring.profiles.active}@{argLine}
然后我必须始终以mvn clean test-Pdev(或其他环境名称)的身份运行测试。是否有办法添加一个条件,即当未提供
-P
部分时,忽略/跳过
argLine
属性


类似于如果{spring.profiles.active}=null,则不包括此属性

您可以尝试在
dev
配置文件(或其他环境名称)中使用属性
{argLine}

<argLine>-Dspring.profiles.active=@{spring.profiles.active} ${argLine}</argLine>
-dsspring.profiles.active=@{spring.profiles.active}${argLine}