How to disable pom.xml validation in IntelliJ IDEA

13,726

Solution 1

With respect, none of SkyWalkers solutions worked for me.

But the following one worked for me:

Simply add this above the property lines:

<!--suppress UnresolvedMavenProperty -->

So you'll end up with:

<!--suppress UnresolvedMavenProperty -->
<git.version>${git.commit.time}.${git.commit.id.abbrev}</git.version>

Solution 2

As it is working fine. I think it would be some cache or may be little bug which has no major effect giving some info. So I want to suggest you some options

Suggestion-1:

You can rebuild your project and then check

Build > Rebuild Project

Suggestion-2:

You can clear your ide's caches

  1. File -> invalidate caches
  2. Then Restart application

Suggestion-3:

Sometimes silly trick may solve the issue.

  1. Right click on the code editor
  2. Hover on Maven and expand
  3. Click on Reimport

Suggestion-4:

There are some ways to solve the issue and also discussion what is happening version to version. You can go through

IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

Suggestion-5:

You can make a try Michał Wróbel's blog: Cannot resolve symbol XYZ in IntelliJ although maven builds sources properly

Suggestion-6:

You can also disable reading pom.xml on every small changes in IntelliJ Idea: Intellij IDEA and Maven, disable reading pom.xml on every small change, even without a save

Solution 3

Try File->Settings->Editor->Inspections->uncheck "Maven Model Inspection" and apply.

Solution 4

The question asks for how to deactivate the verification because of the unfixed IntelliJ bug causing false errors for the syntax "${dynamic.variable}" in dynamic pom.xml variables.

Instead, here is a workaround for the bug, so the false error notification disappears and the maven still accepts the variable and everyone is happy:

Change variable syntax in this order (no joke): 1. "${dynamic.variable}" 2. "{dynamic.variable}" 3. "{$dynamic.variable}"

IntelliJ will now accept it as correct and maven will also parse and accept the dynamic variable without problem. It is obviously an undocumented maven syntax which for some reason has been implemented as the correct and only syntax in IntelliJ IDE.

I hope this helps everyone, despite it not answering the actually asked question, but eliminates the reason for asking it instead.

Have fun :)

Share:
13,726

Related videos on Youtube

Dragan Bozanovic
Author by

Dragan Bozanovic

Java Developer. Author of Keepboard - open source cross-platform clipboard manager.

Updated on September 15, 2022

Comments

  • Dragan Bozanovic
    Dragan Bozanovic over 1 year

    I'm using buildnumber-maven-plugin to get Mercurial changeset as project build number:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
            <execution>
                <phase>initialize</phase>
                <goals>
                    <goal>hgchangeset</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    

    Then I use ${changeSet} property to set build.number property in the same pom.xml:

    <build.number>${changeSet}</build.number>
    

    However, IntelliJ IDEA complains that it Cannot resolve symbol 'changeSet':

    enter image description here

    Also, the module root and the affected pom.xml files are underlined in red in the Project tool window.

    I tried all of the offered Alt+Enter options and Maven configurations in the Settings; nothing helped.

    Everything builds and works fine, I just want to get rid of the annoying error displayed in the IDE. Any suggestion?

    IDE and environment:

    IntelliJ IDEA 2016.1.2
    Build #IC-145.972, built on May 14, 2016
    JRE: 1.8.0_65-b17 amd64
    JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
    
  • Anton Koscejev
    Anton Koscejev almost 8 years
    Upvoting those IntelliJ issues sounds like the best long-term solution. :)
  • Dragan Bozanovic
    Dragan Bozanovic almost 8 years
    The workaround works, thanks. I can live with the dummy value being used in my local environment, because the build on other environments is done with CI tools outside of the IDE anyway.
  • Admin
    Admin almost 8 years
    Turning off the Maven inspections works for most of them, but doesn't seem to affect the "Cannot resolve symbol" one. If it works for you, can you say what version of IDEA it works in, and any other related settings or inspections you might have changed?
  • Adam
    Adam over 6 years
    Good work-around for 2017.2. My pom.xml is now ticked green upper-right corner, no red highlights. Would still be good if Jetbrains fixed the issue though.
  • Adam
    Adam over 6 years
    Spoke too soon. The work-around works where I'm using these dynamic properties in plugin configuration, but it doesn't work in my super-pom where I am using the variables in the project.properties section.
  • Roeland Van Heddegem
    Roeland Van Heddegem over 5 years
    FYI: IDEA-96358 should be fixed