<dependency> <groupId>org.scannotation</groupId> <artifactId>scannotation</artifactId> <version>1.0.4</version> </dependency> import org.scannotation.ClasspathUrlFinder; import org.scannotation.WarUrlFinder; import org.scannotation.archiveclasses.Filter; import org.scannotation.archiveclasses.JarIterator; import org.scannotation.archiveclasses.StreamIterator; public class ScannotationScanner { public static void main(String[] args) throws Exception { String classpath = ClasspathUrlFinder.findClassBase(ScannotationScanner.class); Iterator it; if (classpath.endsWith(".war")) { it = new StreamIterator(WarUrlFinder.findWebInfClassesPath(classpath)); } else if (classpath.endsWith(".jar")) { it = new JarIterator(classpath); } else { it = new StreamIterator(classpath); } Filter filter = new Filter() { public boolean accepts(String filename) { return filename.endsWith(".class"); } }; while (it.hasNext()) { String className = it.next(); System.out.println(className); } } }


上一篇:
下一篇:
切换中文