基于spring扫描某包下面的类文件

private List scanPackage() throws Exception{
   ResourcePatternResolver resolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
   MetadataReaderFactory metaReader = new CachingMetadataReaderFactory(resourceLoader);
   Resource[] resources = resolver.getResources(debugProperties.getPackagePath());
   List readers = new ArrayList<>();
   for (Resource r : resources) {
      MetadataReader reader = metaReader.getMetadataReader(r);
      readers.add(reader);
   }
   return readers;
}

你可能感兴趣的:(基于spring扫描某包下面的类文件)