Home > Back-end >  how does maven-spring-boot-plugin determine the main class?
how does maven-spring-boot-plugin determine the main class?

Time:12-30

I am quite new to the java world, and recently I have been trying to grasp some ideas about how spring-boot works.

I am confused about some questions.

1, when I do mvn install, does the compiler normally compile all the classes in the src/main/java dir, even among them some are not used ?

2, I know somehow the plugin maven-spring-boot-plugin defined in pom.xml does all the magic for a spring application to start up, but, how does it determine which class is the Main-Class ? via traversing all the compiled classes to find one with public static void main ?

CodePudding user response:

  1. Yes, compile everything in the "ClassPath". In this case is the src/main/java you mentioned.

  2. It will look for the main method which is in a class with @SpringBootApplication annotation.

  • Related