Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

Adrian Ciobanu

Greenhorn
+ Follow
since Sep 10, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adrian Ciobanu

I also don't see why this naming matter would be so important. Pivotal makes it important by adding this question to their "Spring Professional Certification Study Guide" from May 2019.

I just saw that a guy (Dominik Cebula) in it's Udemy course says that @RestController is considered a stereotype annotation. He lists @Component, @Controller, @Repository, @Service and @RestController as stereotype but does not mention if he consideres this to be the complete list or not.

A small problem is that if I will get this question on the exam, I will not now what Pivotal's expected answer is.

(Thanks for the welcome, Stephan)
3 days ago
I will add another quote from Iuliana Cosmina's book:

"In Spring 4.0, the @RestController annotation was introduced. This annotation is basically a combination of @Controller and @ResponseBody, and when used on a class, it assumes that all values returned by the methods in this controller should be bound to the web response body.
The @RestController annotation is a specialized version of the @Controller that does more than just mark a component as being used for REST requests; thus it is not considered a stereotype annotation, and was declared in a different package: org.springframework.web.bind.annotation."

My understanding is that @RestController is not considered a stereotype annotation because:

1. All the other stereotype annotations (@Controller, @Repository and @Service) are from org.springframework.stereotype package, but @RestController is part of org.springframework.web.bind.annotation
2. All the other stereotype annotations (@Controller, @Repository and @Service) are used to mark classes (from which a bean will be created) according to a specific purpose. @RestController not only marks classes according to a specific purpose, but also assumes that all values returned by methods in a controller should be bound to the web response body. (The DispatcherServlet is notified that the result of the execution of a controller does not have to be mapped to a view by annotating the method with @ResponseBody)

This is my current understanding. If you have found other relevant informations (maybe in Spring documentation), please post it.
1 month ago