educative.io

How spring boot runs the sql queries although there's nothing in the main method calling it

I declared DDL and DML sql files inside resources folder and when I run the application the database gets updated although in the main method there is only one line:

SpringApplication.run(TennisPlayerApplication.class, args);

does this method make all this ?

Thanks

Hi Mohammad,
Yes, this method is updating the database.
Here is more explanation for the “SpringApplication”:

SpringApplication class is used to bootstrap and launch a Spring application from a Java main method. This class automatically creates the ApplicationContext from the classpath, scan the configuration classes and launches the application. This class is very helpful in launching Spring MVC(https://www.journaldev.com/2433/spring-mvc-tutorial) or Spring REST application using Spring Boot.

A java class with main method, mark it with “@SpringBootApplication” annotation and invoke “SpringApplication.run()” method.

When we will then run the application, we will get the required output.

I hope everything will be clear now.
Feel free to ask if you have any question.