gpt4 book ai didi

spring - 什么是 Spring "stereotype"?

转载 作者:IT老高 更新时间:2023-10-28 13:04:59 24 4
gpt4 key购买 nike

在 SpringSource 博客条目中,以下句子引用了一个刻板印象

Because @Controller is a specialization of Spring's @Component Stereotype annotation, the class will automatically be detected by the Spring container as part of the container's component scanning process, creating a bean definition and allowing instances to be dependency injected like any other Spring-managed component.

这个词刻板印象的用法是指什么?这是一个技术性的 Spring 术语吗?还是只是一般意义上的刻板印象?

最佳答案

JavaDoc稍微说一下。

Annotations denoting the roles of types or methods in the overall architecture (at a conceptual, rather than implementation, level).

stereotype的名词定义来自Merriam-Webster是这样说的:

something conforming to a fixed or general pattern; especially : a standardized mental picture that is held in common by members of a group and that represents an oversimplified opinion, prejudiced attitude, or uncritical judgment

似乎是为了建议正在注释的特定类的角色。这似乎是有道理的,因为通常建议您使用 @Controller 注释 Controller 类,使用 @Service 注释 Service 类等等。

除了明显的组件扫描功能外,Spring 建议它们为您的 AOP 需求做出很好的切入点划分。

关于spring - 什么是 Spring "stereotype"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14756486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com