Careeroza
The Main Class
ShopeaseApplication
package com.shopease;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ShopeaseApplication {
public static void main(String[] args) {
SpringApplication.run(ShopeaseApplication.class, args);
}
}@SpringBootApplication = Three Annotations
| Annotation | What it does |
|---|---|
@SpringBootConfiguration | marks this class as a configuration class (a special @Configuration), so it can hold @Bean methods |
@EnableAutoConfiguration | turns on auto-configuration based on the classpath |
@ComponentScan | scans this package and sub-packages for @Component, @Service, @RestController ... |
What SpringApplication.run Does
- Reads configuration (
application.properties, environment variables, command-line arguments). - Creates the
ApplicationContext(the IoC container). - Scans components and applies auto-configuration, creating all singleton beans.
- Starts the embedded Tomcat server on port 8080.
- Returns the context; the app now waits for HTTP requests.
Tip: Because it is a normal main method, you can run, debug and set breakpoints in the IDE like any Java program: click the green run icon next to main.