/**
* 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 ""; ->可以用于对该Component进行命名,一般情况下default都可以省略,省略的话即为value值,
}
用法:@Component(value="abc") @Component("abc")
/**
* 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 ""; ->可以用于对该Repository进行命名,一般情况下default都可以省略,省略的话即为value值,
}
用法:@Repository("aaa") @Repository(value="aaa")
3,@Service
作用:用于声明一个spring的业务处理层组件。
声明格式:
@Target({ElementType.TYPE}) :表明该注解可以用在类上
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component :Service被Component修饰,表明该注解同Component一样,为spring的一个组件
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)
*/
String value() default "";
/**
* Explicitly specify the name of the Spring bean definition associated
* with this Configuration class. If left unspecified (the common case),
* a bean name will be automatically generated.
* <p>The custom name applies only if the Configuration class is picked up via
* component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}.
* If the Configuration class is registered as a traditional XML bean definition,
* the name/id of the bean element will take precedence.
* @return the suggested component name, if any (or empty String otherwise)
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
*/
String value() default "";
}