我正在编写一个小项目来了解 Maven 和 Spring 框架。要运行我的项目,我运行以下命令:
clean install exec:java -e -DinputFolder=src/main/resources/testCases
有没有办法让 inputFolder 参数在运行时成为强制参数?
谢谢。
最佳答案
Maven Enforcer Plugin可用于要求为您的构建配置属性。 requireProperty规则将完成这项工作。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>inputFolder</property>
<message>inputFolder property must be set</message>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
关于java - 强制 Maven 命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50214072/