Main class of Spring Boot @SpringBootApplication
I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
Search for a command to run...
I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
No comments yet. Be the first to comment.
Spring AI Tool Calling: From Chatbot to AI Agent with @Tool Your AI is smart. It knows an enormous amount. But it's frozen. It doesn't know what time it is right now. It doesn't know what's on your ca
Spring AI Advisors API Explained Series: Spring AI Complete Course — Lecture 4 of 12Reading Time: 8 minutesLevel: Intermediate Most developers stop at ChatClient. That is enough for demos. It is not
Working with Multiple AI Models in Spring AI Spring AI Complete Course — Lecture 3 of 12Previous: Lecture 2 — ChatClient API | Next: Lecture 4 — Advisors API In production AI applications, you rarel
Spring AI ChatClient API: The Fluent Heart of AI Integration Introduction If you've ever tried integrating AI models into a Java application, you know the pain. HTTP clients, API keys scattered everywhere, vendor-specific SDKs that never quite fit. W...
What is Spring AI? — Why Java Developers Need This in 2026 Every AI tutorial you see is in Python. LangChain, LlamaIndex, OpenAI SDK — all Python. But here's the uncomfortable truth: 80% of enterprise backends run Java. So who's building AI into thos...
All Spring Boot Application have one class with main method as an entry point. Our application also has one , It’s UserServiceApplication.java under com.codingsaint.userservice package. If we look at code of this class.
package com.codingsaint.userservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceApplication.class, args);
}
}
Here , we see the class with main as an entry point and annotated with @SpringBootApplication.
A spring boot application starts from the class annotated with @SpringBootApplication ,so there must be one and at most one class with main method signature annotated with @SpringBootApplication.
@SpringBootApplication is the entry point of any Spring Boot application, This annotation is actually a combination of few other annotation, @SpringBootConfiguration , @EnableAutoConfiguration and @ComponentScan
It tells that this class acts as a configuration class and can be used alternatively for @Configuration which is another standard annotation of Spring
It indicates that Spring will guess automatically the configuration classes that application will need and configure them. This is the reason Spring boot is said to have a very opinionated approach. Tough it’s opinionated approach doesn’t stop you to configure the way you wanted.EnableAutoConfiguration looks at the classpath to find the beans you would require at runtime and configure them.
This annotation helps you to scan all Spring beans. It searches bean in packages you ask it to search, provided via value to annotation viz @ComponentScan({“my.awesome.package”}).
@SpringBootApplication with inbuilt @ComponentScan searches the packages in which main class is, and the packages below it. It means with our application structure it will search any class which is in com.codingsaint.userservice and sub packages i.e. com.codingsaint.userservice.* like com.codingsaint.userservice.vo or com.codingsaint.userservice.dao etc.
Now let’s make our application serve some web url requests . Since will start with a RESTful application , we will create controllers and map requests to its methods. We will ensure that if someone sends a URL request and it is valid , our application sends a valid response.