SpringApplication.run main method

You need to run SpringApplication.run() because this method starts whole Spring Framework. Code below integrates your main() with Spring Boot.


public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);


public class ReconTool implements CommandLineRunner {

    public void run(String... args) throws Exception {

    public static void main(String[] args) {
        // Recon Logic

Why not SpringApplication.run(ReconTool.class, args)

Because this way spring is not fully configured (no component scan etc.). Only bean defined in run() is created (ReconTool).

Example project: https://github.com/mariuszs/spring-run-magic

Leave a Comment