Issue
I'm new to SpringBoot and I've been a long time without coding with Java. In my mind this doesn't make sense. Why is the SpringApplication.run()
inside the class that it runs ?
Like so:
@SpringBootApplication
public class ConsumingRestApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumingRestApplication.class, args);
}
}
Solution
Because there is no practical need.
Technically you could do something like that:
@SpringBootApplication
public class ConsumingRestApplication {}
public class Init {
public static void main(String[] args) {
SpringApplication.run(ConsumingRestApplication.class, args);
}
}
But you wouldn't gain anything from it, that's why it's just simplified into one class with the annotation and the main method.
Answered By - dunni
Answer Checked By - David Marino (JavaFixing Volunteer)