“@Service 和 @Component 的区别”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) (建立内容为“1”的新页面) |
Jihongchang(讨论 | 贡献) |
||
第1行: | 第1行: | ||
− | + | @Service 其实就是 @Component<syntaxhighlight lang="java"> | |
+ | @Target({ElementType.TYPE}) | ||
+ | @Retention(RetentionPolicy.RUNTIME) | ||
+ | @Documented | ||
+ | @Component | ||
+ | public @interface Service { | ||
+ | |||
+ | /** | ||
+ | * The value may indicate a suggestion for a logical component name, | ||
+ | * to be turned into a Spring bean in case of an autodetected component. | ||
+ | * @return the suggested component name, if any (or empty String otherwise) | ||
+ | */ | ||
+ | @AliasFor(annotation = Component.class) | ||
+ | String value() default ""; | ||
+ | |||
+ | } | ||
+ | </syntaxhighlight> |
2024年7月17日 (三) 23:08的最新版本
@Service 其实就是 @Component
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Service {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any (or empty String otherwise)
*/
@AliasFor(annotation = Component.class)
String value() default "";
}