5

In my project's POM, I use maven-resources-plugin to set some properties from a file. However, Intellij flags these property references in the POM with the error "cannot resolve symbol", presumably because it cannot see them being defined anywhere. Is there a way to suppress this error?

Andy Dennie
  • 6,012
  • 2
  • 32
  • 51

4 Answers4

6

Warning: The solution to define the property blank as vikingsteve mentioned is very dangerous because in Maven 3 properties which are declared in pom.xml could not be changed by other plugins.

So if you have one plugin which sets a property and another plugin which reads the value of the property it will always get an empty string if you initialize it in the pom.xml.

In fact you can't define it in the pom.xml but i have no idea what i can do to eliminate the IntelliJ IDEA warning. For now i have to disable the "Maven model inspection". :-(

Josef Reichardt
  • 2,778
  • 3
  • 22
  • 37
0

The best way I see to solve the issue is to use the following comment:

<!-- suppress UnresolvedMavenProperty -->

Empty properties are not overwritten or may be a risky operation as @Josef mentioned.

Julia
  • 1,950
  • 1
  • 9
  • 22
-1

Yes, you can open Settings (spanner icon), go to Project Settings -> Inspections and then disable the inspection Maven -> Maven Model Inspection.

Alternatively, you might like to try defining "blank" values for the properties, and see if the plugin successfully overwrites them.

<properties>
     <myproperty></myproperty>
</properties>

Good luck!

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
-1

Error “cannot resolve symbol” can occur if you open a directory maven project, but intellij project has not yet been created. Why does the "Maven model inspection" there is such a relationship - is not clear, but it helped me.

Stas Yak
  • 109
  • 1
  • 3
  • Hey Stas, in either case you should edit this and clarify what you mean by the model inspection. I can't tell if you're asking a question or proposing a solution. Hope this helps! – jamesmortensen Nov 03 '13 at 00:15
  • I mean, that there is a project - "Inspection" is working correctly. There is no "idea"-project, the properties are highlighted as "cannot resolve symbol". – Stas Yak Nov 07 '13 at 07:08