@Service annotation
@Service
is an annotation in Spring Framework that is used to indicate that a particular class is a service component in the application.- When a class is annotated with
@Service
, Spring considers it as a service bean and manages its lifecycle, including dependency injection and transaction management.
A simple service
@Service
class StarterService {
fun getMessage(): String {
return "hello!"
}
}