2013-07-11 182 views
3

我已經使用Maven設置了Scala項目。但它不編譯。我得到了一些奇怪的錯誤,比如缺少一些基本的東西其中一些是:斯卡拉錯誤「value toInt不是字符串的成員」和「找不到:type」

[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/Node.scala:17: error: not found: type Map 
[INFO] var attributes: Map[String, String] = null 
[INFO]     ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/CompanySiteEmailCrawlerController.scala:137: error: not found: type Set 
[INFO] private def addEmailToCompanyList(harvestedRecordsCompanyList: List[Company], company: Company, emailSet: Set[String],[INFO]                           ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/CompanySiteEmailCrawlerController.scala:186: error: value toInt is not a member of String 
[INFO]  lineFrom = args(3).toInt 
[INFO]      ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/crawler4j/Crawler4jAdaptee.scala:25: error: not found: value classOf 
[INFO] private val log: Logger = Logger.getLogger(classOf[Crawler4jAdaptee]) 
[INFO]           ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/crawler4j/Crawler4jAdaptee.scala:126: error: not found: type Map 
[INFO]  val attributesMap: Map[String, String] = attributes.map(a => (a.getKey, a.getValue)).toMap 
[INFO]      ^

所以MapSet集合都不會被發現那位和toInt方法不適用於字符串的工作。在我pom.xml我:

<dependencies> 
    <dependency> 
     <groupId>org.scala-lang</groupId> 
     <artifactId>scala-library</artifactId> 
     <version>2.10.2</version> 
    </dependency> 
</dependencies> 

<build> 
    <sourceDirectory>src/main/scala</sourceDirectory> 
    <plugins> 
     <plugin> 
      <groupId>org.scala-tools</groupId> 
      <artifactId>maven-scala-plugin</artifactId> 
      <version>2.15.2</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>compile</goal> 
         <goal>testCompile</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<repositories> 
    <repository> 
     <id>scala</id> 
     <name>Scala Tools</name> 
     <url>http://scala-tools.org/repo-releases/</url> 
     <releases> 
      <enabled>true</enabled> 
     </releases> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
    </repository> 
</repositories> 
<pluginRepositories> 
    <pluginRepository> 
     <id>scala</id> 
     <name>Scala Tools</name> 
     <url>http://scala-tools.org/repo-releases/</url> 
     <releases> 
      <enabled>true</enabled> 
     </releases> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
    </pluginRepository> 
</pluginRepositories> 

,當我在理念上運行它,我得到同樣的錯誤,雖然IDE不抱怨的代碼,只有編譯器。我對Scala很陌生。你能幫我在這裏嗎?

+0

與週期類似的東西。我不能使用'for(i < - 1到10)',而不得不使用'for(i < - Range(0,10))',否則我得到'不是Int成員的錯誤' 。 – Vic

回答

1

導入scala.collection.immutable解決了收集問題,對於classOf問題,我找到了解決方法 - 使用getClass代替。 toInt問題仍未解決。儘管有一個解決方法 - 使用該定義中的確切代碼:java.lang.Integer.parseInt。我有一種感覺,這也是一個進口問題。