标签:ima one bsp ado static policy png 分享 getbean
@Target(ElementType.TYPE) //jdk5注解,表示作用目标类型,是类、方法还是变量等 @Retention(RetentionPolicy.RUNTIME)//jdk注解,表示该注解会保存多久,生命周期相关 @Documented//jdk注解,表示是否被javadoc命令导出文档 @Configuration //组合Configuration注解 @ComponentScan //组合ComponentScan注解 public @interface WiselyConfiguration { String[] value() default {}; }
新注解使用类:
@WiselyConfiguration("com.wzy.bj.myannotation") public class DemoConfig { }
测试服务类:
@Service public class DemoService { public void doService(){ System.out.println("doing my demoService,,,,,"); } }
public class AnnotationMain { public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DemoConfig.class); DemoService demoService = context.getBean(DemoService.class); demoService.doService(); context.close(); } }
测试结果:
标签:ima one bsp ado static policy png 分享 getbean
原文地址:https://www.cnblogs.com/nevermorewang/p/8996618.html