gpt4 book ai didi

maven - 当属性值字符串与属性名称相同时,是否可以转义 maven 属性插值?

转载 作者:行者123 更新时间:2023-12-04 08:55:24 24 4
gpt4 key购买 nike

我正在尝试定义一个 Maven 属性:

<properties>
<property>$${property}</property>
</property>

Maven 尝试扩展 ${property} 并且我收到以下错误:
[ERROR]     Resolving expression: '${property}': Detected the
following recursive expression cycle in 'property': [property] -> [Help 2]

我尝试了各种组合来试图逃避它,但没有成功:
$$
\$
\$$

等等等等

注意:当属性值与名称不同时,插值会被转义。

这可能吗?

最佳答案

由于您似乎无法构建 Maven 属性(即使具有中间属性),也许您可​​以保留 2 个单独的属性并将它们连接到您需要的位置。假设您想在文件中填充某些属性。

在 POM 中定义 2 个变量:

<properties>
<property>{property}</property>
<dollar>$</dollar>
</properties>

在文件中定义属性时使用两者:
# variable from file which is to be filtered
whatever=${dollar}${property}

过滤后你会得到:
# variable from file which is to be filtered
whatever=${property}

使用 &amp; 怎么样? ?一个配置如:
  <properties>
<property>&amp;{property}</property>
</properties>

...

<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>0.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>property=[${property}]</echo>
</echos>
</configuration>
</plugin>
</plugins>

将输出:
[INFO] --- echo-maven-plugin:0.2:echo (default) @ XXXX ---
[INFO] property=[&{property}]

关于maven - 当属性值字符串与属性名称相同时,是否可以转义 maven 属性插值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23987112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com