自动扫描应用指定类的子类

ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
        provider.addIncludeFilter(new AssignableTypeFilter(Abc.class));
        Set components = provider.findCandidateComponents("com.*****");
        for (BeanDefinition component : components){
            try {
                Class cls = Class.forName(component.getBeanClassName());
                System.out.println(cls.getSimpleName().toLowerCase().substring(0, cls.getSimpleName().length() - 3) + "_id");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }

 

你可能感兴趣的:(java,java,子类,扫描)