语法错误,插入" ... VariableDeclaratorId"完成FormalParameterList [英] Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList

查看:1218
本文介绍了语法错误,插入" ... VariableDeclaratorId"完成FormalParameterList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用此代码时遇到一些问题:

I am facing some issues with this code:

import edu.uci.ics.crawler4j.crawler.CrawlConfig;
import edu.uci.ics.crawler4j.crawler.CrawlController;
import edu.uci.ics.crawler4j.fetcher.PageFetcher;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer;

public class Controller {

     String crawlStorageFolder = "/data/crawl/root";
     int numberOfCrawlers = 7;

     CrawlConfig config = new CrawlConfig();
     config.setCrawlStorageFolder(crawlStorageFolder);
     /*
      * Instantiate the controller for this crawl.
      */
     PageFetcher pageFetcher = new PageFetcher(config);
     RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
     RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
     CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);

     /*
      * For each crawl, you need to add some seed urls. These are the first
      * URLs that are fetched and then the crawler starts following links
      * which are found in these pages
      */
     controller.addSeed("http://www.ics.uci.edu/~lopes/");
     controller.addSeed("http://www.ics.uci.edu/~welling/");
     controller.addSeed("http://www.ics.uci.edu/");
     /*
      * Start the crawl. This is a blocking operation, meaning that your code
      * will reach the line after this only when crawling is finished.
      */
     controller.start(MyCrawler.class, numberOfCrawlers);
 }

我收到以下错误:


语法错误,插入...... VariableDeclaratorId完成
FormalParameterListon
config.setCrawlStrorageFolder(crawlStorageFolder)

"Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList" on config.setCrawlStrorageFolder(crawlStorageFolder)


推荐答案

你不能在类体中直接拥有这样的任意代码。它必须位于方法(或构造函数或初始化块)中。

You can't have arbitrary code like that directly in the class body. It must be in a method (or constructor, or initialization block).

这篇关于语法错误,插入" ... VariableDeclaratorId"完成FormalParameterList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆