简体   繁体   English

Maven可以忽略缺少的系统属性吗?

[英]Can Maven ignore a missing system property?

If I have the following in my pom file: 如果我的pom文件中包含以下内容:

<properties>
    <mySystemProperty>${mySystemProperty}</mySystemProperty>
</properties>

When I build using "mvn clean install -DmySystemProperty=someData", it builds successfully. 当我使用“ mvn clean install -DmySystemProperty = someData”进行构建时,它会成功构建。 If I build it using "mvn clean install", where I don't need to specify the system property, Maven gives me this error: 如果我使用“ mvn clean install”构建它,而无需指定系统属性,那么Maven会给我这个错误:

Resolving expression: '${mySystemProperty}': Detected the following recursive expression cycle in 'mySystemProperty'

Is there a way to get maven to ignore the missing system property? 有没有办法让Maven忽略缺少的系统属性? If not, is there a way to default it? 如果没有,是否有默认方法?

Solved it. 解决了。 Using the same name for the system variable and maven variable caused the problem. 为系统变量和maven变量使用相同的名称会导致此问题。 Renaming the system variable fixed the error. 重命名系统变量可修复该错误。

<properties>
    <mySystemProperty>${sysProperty}</mySystemProperty>
</properties>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM