0

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.

Ankit
  • 4,426
  • 7
  • 45
  • 62
  • 1
    Yes , seems you think right https://stackoverflow.com/questions/11508405/are-spring-mvc-controllers-singletons – Ali D.A. May 09 '20 at 08:53

1 Answers1

0

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