@Component
该注解代表该类为Spring的组件:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
public @interface Component {
/**
* 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)
*/
String value() default "";
}
一般不直接使用该注解,而使用:
@Configuration
@Service
@Repository
@Controller
指向更加明确的注解。
@Configuration
代表为配置类。
@Target(ElementType.TYPE