简体   繁体   中英

What happens “under the hood” when IntelliJ runs a Maven project?

You all know the process of putting dependencies in pom.xml file and running "mvn clean install". When this command runs, the jar files of the dependencies are downloaded to the.m2 repository.

When we run our application using IntelliJ and Run/Debug Configuration window, how does IntelliJ know where to look for the jar files of the dependencies? Every GUI operation in IntelliJ actually replaces command-line operations. What are the command-line operations that are committed "behind the scene" when we click the "run" button. I believe that class files are built from the java source files, but I cannot see any clue in Run/Debug Configuration window that directs us to.m2 directory.

You can see the -classpath IDE uses in the very first line in Run(or Debug if you launch in Debug mode) tool window. This list consists of the entries you see in the module's Dependencies tab .

Important note: it is so unless you are using delegate Run/Build actions to Maven (Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Runner | Delegate IDE build/run actions to Maven ) or Gradle (Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using ) in IDE. Then IDE actually uses Maven (or Gradle) to run the application.

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