2013-02-12 57 views

回答

0

這應該讓你開始(看控制檯輸出,它纔有意義):

import com.google.common.collect.Multimap; 
import org.reflections.Reflections; 

import java.util.Map; 

public class PackageWalker { 
    public PackageWalker() {} 

    public void walk() { 
     Reflections reflections = new Reflections("org.reflections"); 
     for (String mmapName : reflections.getStore().getStoreMap().keySet()) { 
      System.out.println("KEY["+mmapName+"]"); 
      Multimap<String,String> mmap = reflections.getStore().getStoreMap().get(mmapName); 
      for (Map.Entry<String,String> entry: mmap.entries()) { 
       System.out.println(" PAIR[ "+entry.getKey()+"="+entry.getValue()+" ]"); 
      } 
     } 
    } 

    public static void main(String[] args) { 
     new PackageWalker().walk(); 
    } 
} 

以下JAR,並且需要它們的依賴(使用常春藤格式):

<dependency org="org.reflections" name="reflections" rev="0.9.8"/> 

這裏是我的項目文件夾: http://www.filedropper.com/laboratorytar

你只需要確定Ivy是使用ant安裝的(本質上是將ivy.jar放入你的ANT_HOME/lib(或〜/ .ant/lib/on * nix中),它就會工作)。

+0

我的項目不是maven項目。我已經從谷歌頁面下載了jar文件,但無法弄清楚如何將它放入我的螞蟻項目 – user1801813 2013-02-13 02:55:21

+0

我只是將它作爲參考,以便讓它發揮作用。你應該看看常春藤和螞蟻,很容易設置,它會爲你做依賴,所以你不必管理罐子(花了我30分鐘才能使它工作:http://ant.apache.org/ivy/Ivy比Maven容易得多)。 把所有的罐子放進一個lib文件夾,當你從螞蟻運行它時,將這些罐子添加到classpath(通常的做法是你可以做外部的罐子)。 – 2013-02-13 16:33:53

相關問題