0
我正在设置类似于SpringBootApplication Spring Boot提供的Spring“元注释”。我已经能够使用这个约定成功地设置ComponentScan和EnableAutoConfiguration注解,但是我无法成功地将值属性传递给ImportResource。有没有人知道如何在“元注释”中使用Spring的ImportResource注释?
这里是想我做一个简单的例子:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@ComponentScan(basePackages = {"com.my.package.example"})
@EnableAutoConfiguration
@ImportResource
public @interface MyMetaAnnotationExample {
String[] value() default {};
}
然而,编译器会抱怨,没有属性被传递到ImportResource。当我尝试传递该属性时,我没有希望通过MyMetaAnnotationExample传递的值,因此我无法设置这些值。
课程的ComponentScan作品,因为这是需要硬编码的东西,但ImportResource是希望通过在一些有价值的东西。