Reflections on Sprin annotations

Reflections on Spring annotations

1, spring boot commonly used annotation what?
https://blog.csdn.net/lipinganq/article/details/79155072
@Component no clear role components
@Service in the business logic (Service level) using
@Repositpry use in data access layer (dao layer)
@Controller for labeling control layer components
@RestController
really sum up, spring is to be scanned and registered as a bean. It is registered as a bean what good? In fact, this is the answer to the second question.

2, spring boot why comment?
First, let me comment. ( Https://blog.csdn.net/briblue/article/details/73824058)
the Java annotation is time for a java class or method to annotate, annotation can define the parameters given. For example, now give @A comments, we can give A comment parameters such as id = "1", Msg = "hello". Then use the A notes to annotate a method when it is possible to obtain A comment on this method, the A annotation attributes or parameters used in this method. See the FIG.

figure 1
figure 1

After you understand what annotations are, to understand why spring boot Footnote? This can be explained @Requestmapping comment. Refer to ( https://blog.csdn.net/zero__007/article/details/80642989,https://www.cnblogs.com/taotingkai/p/8438360.html).
@Requsetmapping annotation is a method and a corresponding request url associate.
In fact, mainly the following diagram

figure 2
Note: This article refers to the others answered, invasion deleted

Guess you like

Origin blog.csdn.net/huqianlei/article/details/89931467