Spring Boot | Tutorial 7: Stereotypes Annotations

  • Stereotype annotations - @component, @controller ,@service, @repository.
  • What is Stereotype Annotation?
  • is a tag on the cloud that gives general informations about class. sets role of that class.
  • 5 annotations - Component, Controller, Service, Repositories, Indexed(deprec)
  • Component - for all spring managed element. In start, main class scans all component annotation. Container creates while scanning project, making dependency injection available.
  • Controller - has a role of controller. Directs traffic and route request. reroute.
  • There's RestController. For Controller In MVC event controller responsce, the response is View(html, css,js). RestController is for json and xml. So RestContorller is @Controller + @ResponseType.
  • Service - role of service. runs business logic.
  • Repository - handle the data access logics. DAO.
  • example - hibernate as persistent layer. manages native access.
  • Controller, Service, Repository is child of Component.
  • These annotations will make beans. Then it is ready for DI
  • User request -> Controller -> Service -> Repository -> DB -> all the way back to user.
  • Name of instance - bean name is same as class name. EmpController classs -> empController bean instance
  • scope of beans - singleton, proto, request, session, global session. default is Singleton.
  • demo - lets use actuator. localhost:8080/actuator
  • shows all the bean data
  • @RestController(value="~~") changes name, and @scope changes scope type.


Composed 191 Viments


Published on Nov 16, 2020

Send Viment

Comments 0

Viments for this video by others

There's no pre-existing Viments

Facebook Kakao Naver Twitter


Copy & Paste following HTML

Viment Text

Copy & Paste following Text