@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@ComponentScan
public @interface WiselyConfiguration {
String[] value() default {};
}
@Service
public class DemoService {
public void outputResult() {
System.out.println("从组合注解配置照样得到的Bean");
}
}
@WiselyConfiguration("ch3.annotation")
public class DemoConfig {
}
public class Main {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DemoConfig.class);
DemoService demoService = context.getBean(DemoService.class);
demoService.outputResult();
context.close();
}
}
spring boot组合注解与元注解
最新推荐文章于 2024-01-09 18:00:29 发布