自动配置
Spring使用@Configuration作为配置的注解,其实这个注解没什么东西,使用@Component作为元注解,和@Service、@Repository差不多,只是起了一个新的名字,表示了更具体的含义,当Spring发现某个类使用了@Configuration标注了,就去将该类下使用@Bean注解的方法创建bean并放入到容器中。
@Configuration
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {
@AliasFor(annotation = Component.class)
String value() default "";
}
关于自动