1
我收到以下錯誤匹配的構造函數:Groovy:在找不到「子」
Could not find matching constructor for: org.crawler.CrawlerUtils$fetch(org.series.crawler.site.SubSiteA).
我試圖使用線程。我只用過一次線程,而且我正在嘗試執行與其他項目中所做的相同的操作。
我:
Class CrawlerUtils {
public static void crawlSites(List<Site> sites) {
def pool = Executors.newFixedThreadPool(MAX_THREADS)
def ecs = new ExecutorCompletionService<Void>(pool);
sites.each { ecs.submit(new fetch(it), Void) }
sites.each { ecs.take().get() }
pool.shutdown()
}
class fetch implements Runnable {
Site site
fetch(Site site) {
this.site = site
}
public void run() {
site.parse()
}
}
}
我想這些(uglies)方法:
- 創建一個接口(使用的ISite網站代替網站網站內取構造函數)
- 在每個子類中放入一個構造函數取類
- 將一個構造函數,調用超()
任何想法,每個子類中?
,你是否嘗試使其成爲一個頂級類?我想知道這是否是一個內心階層,這是問題所在。我不記得Groovy中的嵌套類是否像在Java中一樣工作。 –