简体   繁体   中英

Why does 'Build Project' fail whereas Run (Maven configuration) succeed?

Case in question: A Maven based project that has a Maven Run Configuration with its 'Command line' parameters defined as clean install .

Clicking the green arrow to invoke 'Run my_maven_config' downloads all necessary packages from Nexus and completes the build successfully.

Selecting 'Build Project' however, invokes a seemingly similar process but after building successfully for quite a while, it fails on a missing Hibernate package.

Why is this difference?

Shouldn't the build part of 'Run' be identical to the "standalone build"?

They are not identical. IntelliJ IDEA imports the external project model from Maven and converts it to the internal project model. It's not 100% accurate, some Maven plug-ins are not supported, some dependencies may fail to resolve, etc.

See this answer to perform the diagnostics. Try re-importing the project (delete .idea directory first if it doesn't help).

Delegating build/run actions to Maven as it can be done now with Gradle will be supported later (probably in IntelliJ IDEA 2018.3).

Now IntelliJ IDE allow to delegate Build actions to maven. Go to Preferences and search for "Delegate IDE build actions to maven".

So when you build a project, IntelliJ IDEA invokes the appropriate Maven goals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM