Scala错误“值toInt不是String的成员”和“not found:type”

时间:2013-07-11 18:59:08

标签: scala

我使用Maven设置了Scala项目。但它不会编译。我得到一些奇怪的错误,比如基本缺失的东西。其中一些是:

[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集合不是fount,而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>

我在Idea中运行它时遇到的错误,虽然IDE没有抱怨代码,只有编译器会这样做。我对Scala很新。你能帮帮我吗?

1 个答案:

答案 0 :(得分:1)

导入scala.collection.immutable解决了收藏问题,针对classOf问题找到了解决方法 - 改为使用getClasstoInt问题仍未得到解决。但是有一种解决方法 - 使用该定义中的确切代码:java.lang.Integer.parseInt。我觉得这也是进口产品的问题。