Intellij:无法识别skipTests标志

问题描述 投票:0回答:3

我在 pom.xml 中获得了以下 Maven 配置。 Intellij Ultimate 2018.1 将skipTests 变量突出显示为红色

无法解析符号“skipTests”

但是为什么呢?这是一个常见的maven环境变量。

<build>
 <plugins>
  <plugin>
    <!-- exec yarn -->
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
      ...
      <execution>
        <id>yarn-test</id>
        <phase>process-test-classes</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>yarn</executable>
          <skip>${skipTests}</skip>
          <arguments>
            <argument>test</argument>
          </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>
 </plugins>
</build>
maven intellij-idea pom.xml
3个回答
4
投票

我通过放置 intellij 忽略评论解决了这个问题

<!--suppress MavenModelInspection -->

在那条特定的 pom 线上。


0
投票

尝试重新启动Intellij Idea,有时错误只有重新启动后才会消失。如果这不起作用,请尝试更改 Maven 的版本。

编辑

检查此链接,我认为这会对您有所帮助如何在 IntelliJ IDEA 中禁用 pom.xml 验证


0
投票

就我而言,解决方案是也在属性部分添加默认值:

<properties>
    <java.version>17</java.version>
    <skip.ut>false</skip.ut>
</properties>

然后在我的 Surefire 插件的插件部分中,skip.ut 不再是红色的:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
    <skipTests>${skip.ut}</skipTests>
</configuration>
</plugin>
© www.soinside.com 2019 - 2024. All rights reserved.