Maven package works but Intellij's build fails
I know this is late but executing mvn idea:idea
solves the issue.
The command re-generates the crucial IntelliJ IDEA files: ipr
, iml
, and iws
, and thus re-align them with your pom.xml
.
Documentation: https://maven.apache.org/plugins/maven-idea-plugin
The plugin is retired but still (as of 05.06.2021) works like magic :)
Try to delete all .iml and your POM.Then copy and paste your POM again to your project and re-open and re-import it.