“@Service 和 @Component 的区别”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
(建立内容为“1”的新页面)
 
 
第1行: 第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 "";

}