gpt4 book ai didi

xml - 在 IntelliJ 的 pom.xml 中使用 @ 符号“无法解析符号”

转载 作者:数据小太阳 更新时间:2023-10-29 02:44:21 25 4
gpt4 key购买 nike

我在 Maven pom.xml 文件中遇到一个错误,当我有一个包含 2 个 @ 符号且中间有一些字符的属性时。唯一的消息是

cannot resolve symbol 'symbol'.

这不会导致构建或运行应用程序时出错,但会导致项目窗口出现红色下划线(使用 IntelliJ IDEA 14)。

我已尝试禁用对 XML 和 Maven 的检查,但问题仍然存在。

如果我关闭 IntelliJ 并重新打开,只要我不重新打开 pom.xml 文件,错误就不会出现。

我找不到任何关于 2 个 @ 符号在 Maven 或 XML 中可能意味着什么的引用,所以我倾向于认为它是 IntelliJ 特定的东西。

导致此错误的原因是什么以及如何修复它(除了更改属性值或从不打开文件之外)?

screenshot

最佳答案

长话短说@@${at}${at} (或者:@{}${at}{} 对于 failsafe argLine 在 IDEA 中)

虽然略有不同,但我的案例(涉及 IntelliJ IDEA v2017.3.5)已通过 this answer by Mike 的解决方法解决,即定义 @符号作为一个单独的属性,例如<at>@</at> ,即在您的测试用例中:<at>@</at><myproperty>${at}hello!${at}</myproperty> .

这个解决方案似乎至少适用于 argLine maven-surefire-plugin 中使用的选项(v2.21.0) 和 maven-failsafe-plugin (v2.21.0),我需要为 jacoco-maven-plugin 的代码覆盖代理包含 JVM 参数(v0.8.0)。必须在运行时使用 ${..} 读取原始属性(编译时值为 @{..}) (参见 failsafe docs ),一个在 IntelliJ 中无效的术语。所以对于我来说,我们有:${..}@{..}${at}{..}

<project ...>
:
<properties>
<at>@</at>
:
<argLine>...</argLine>
<my.jacoco.args/>
</properties>
:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>my.jacoco.args</propertyName>
:
</configuration>
</execution>
:
</executions>
</plugin>

<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<argLine>${at}{my.jacoco.args} ${at}{argLine}</argLine>
:
</configuration>
</execution>
:
</executions>
</plugin>
:
</plugins>
</build>
</project>

关于xml - 在 IntelliJ 的 pom.xml 中使用 @ 符号“无法解析符号”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35704122/

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