I am learning Spring and Spring Boot. In my Spring boot app, I am using @RestController annotation for one of my classes which receives requests and processes them accordingly.
@RestController
public class SampleController {
......
}
I want to ask would this class annotated with @RestController be a singleton class? My thought is that this SampleController would also be a bean and since the default scope is Singleton, it would be a Singleton class. I want to ask whether I am thinking right.
Yes, you are right. Any bean you creating via annotations @Component, @Service, @Repository, @Controller, @RestController and @Bean of course by default have Singleton scope. Check Bean scope