k13i
k13i

Reputation: 4351

Run Spring boot project from Maven or IDE

I've created Spring Boot based on Maven project as described in one of the official guides. I use IntelliJ. Now I can run project in one of two ways:

  1. Click on green arrow next to main method
  2. Type mvn spring-boot:run in the command line

What's the difference between these two? Which one should I prefer and why? What does IntelliJ use internally to build the project?

Upvotes: 1

Views: 1877

Answers (1)

anothernode
anothernode

Reputation: 5397

The difference is that in case 1) IntelliJ starts the JVM and runs your app and in case 2) Maven does the same.

In development I would recommend to run the Spring Boot application via IntelliJ instead of Maven. If you run it with Maven, you bypass IntelliJ in a way so it will be less aware of what's going on and therefore less able to leverage it's assistance features. I'm not sure if the debugger will even work, if you start the app with mvn spring-boot:run.

IntelliJ internally uses the JDK that you configured for your project to compile your Java code and if it's a Maven project it also uses Maven to assemble the classes into an app. That last part of your question is extremely broad if one would attempt to answer it in detail. But in practice, when developing a Spring Boot app, you rarely need to worry about it anyway, to be honest.

Upvotes: 2

Related Questions