【问题标题】:Crawler4j with Grails App throws error带有 Grails 应用程序的 Crawler4j 抛出错误
【发布时间】:2014-06-25 23:12:23
【问题描述】:

对于有经验的人来说,这可能是一个非常基本且愚蠢的问题。但请帮忙。我正在尝试按照this 教程在我的 Grails 应用程序中使用 Crawler4j。 我知道它的 Java 代码,但我在一个名为 CrawlerController.groovy 的控制器类中使用它。

我添加了 jar 文件,但是当我写 CrawlConfig crawlConfig = new CrawlConfig() 它给我一个编译器错误,说“Groovy 无法解析类”。我刷新了依赖项并尝试了一切。可能是因为我是初学者,所以我错过了一些东西。这是我到目前为止所写的,所有的 import 语句和 CrawlConfig 语句都会抛出错误:

import edu.uci.ics.crawler4j.crawler.Page;
import edu.uci.ics.crawler4j.crawler.WebCrawler;
import edu.uci.ics.crawler4j.parser.HtmlParseData;
import edu.uci.ics.crawler4j.url.WebURL;
class CrawlerController extends WebCrawler {
    public static void main(String[] args) {
    CrawlConfig crawlConfig = new CrawlConfig()

    }
}

`请帮忙。谢谢。

【问题讨论】:

  • 它说的是什么类?你是怎么加罐子的?您可以将 compile 'edu.uci.ics:crawler4j:3.5' 添加到您的 BuildConfig 依赖项中......您是这样做的,还是您下载了大量的东西并将其放在某个地方?
  • 我更新了问题。尝试在 buildconfig 中添加该行,不起作用。我从 crawler4j 网站下载了 jar 文件,然后在我的 grails IDE 中,我添加了外部 jar。就这样。错误说:Groovy: Unable to resolve class edu.uci.ics.crawler4j.crawler.Page 和所有其他导入类似。
  • “CrawlConfig 语句抛出错误”
  • 编辑 buildconfig 并运行 grails compile 就足够了...你看到它获取他的 jars 了吗?显然,如果他的罐子在类路径中的其他地方,他可能会以其他方式破坏它
  • 是的,我很抱歉。更新了评论。

标签: grails groovy crawler4j


【解决方案1】:

只需刷新您的依赖项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-15
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2019-08-08
    相关资源
    最近更新 更多