spring 提供了实现
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); MetadataReaderFactory metaReader = new CachingMetadataReaderFactory(); Resource[] resources = resolver.getResources("classpath*:com/chuanyi/ecard/bean/in/*.class"); ClassLoader loader = ClassLoader.getSystemClassLoader(); for (Resource resource : resources) { MetadataReader reader = metaReader.getMetadataReader(resource); String className = reader.getClassMetadata().getClassName(); Class<?> clazz = loader.loadClass(className); classList.add(clazz); System.out.println( clazz ); }