Spring @AutoConfigureAfter 注解

@AutoConfigureAfter 在加载参数类之后再加载当前类 它的value 是一个数组
一般配合着@import 注解使用 ,在使用import时必须要让这个类先被spring ioc 加载好 所以@AutoConfigureAfter必不可少

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface AutoConfigureAfter {

    /**
     * The auto-configure classes that should have already been applied.
     * @return the classes
     */
    Class<?>[] value() default {};

    /**
     * The names of the auto-configure classes that should have already been applied.
     * @return the class names
     * @since 1.2.2
     */
    String[] name() default {};

}

@Configuration
@AutoConfigureAfter(ClassA.class)
@Import(ClassA.class)
public class DemoConfig {

}

@Configuration
public class ClassA {

}

猜你喜欢

转载自blog.csdn.net/baidu_36327010/article/details/82109069
今日推荐