@Service
A Spring annotation that marks a class as a service bean so component scanning discovers and creates it.
In more detail
@Service is a specialisation of @Component that documents intent: this class holds application logic. Other stereotypes include @Repository and @Controller.
Example
@Service public class GreetingService { ... }Related terms
- component scanning — Spring searching the application's packages at startup for classes marked with annotations such as @Service and registering them as beans.
- Spring bean — An object that the Spring container creates, configures and manages, and can inject into other beans.
- service layer — The layer of an application that holds use cases and business rules, sitting between controllers and repositories.
Taught in
- Dependency Injection And The IoC Container — Modern Java: Virtual Threads & High-Throughput Services