This is Spring bean source.
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Bean {
@AliasFor("name")
String[] value() default {};
@AliasFor("value")
String[] name() default {};
Autowire autowire() default Autowire.NO;
String initMethod() default "";
String destroyMethod() default AbstractBeanDefinition.INFER_METHOD;
I had noticed that String[] value() default {};
. It means that we have to use String Array. But I use the code below, passed a String there, It still works, please tell me why.
@Bean("user")
public UserBean get() {
return new UserBean();
}