Reputation: 1888
I've set up Scala project using Maven. It does not compile however. I get strange errors like something very basic is missing. Some of them are:
[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] ^
So Map
and Set
collections are not fount and toInt
method doesn't work for Strings. In my pom.xml
I have:
<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>
The same errors I get when I run it in Idea, although the IDE does not complain about the code, only the compiler does. I am quite new to Scala. Can you please help me out here?
Upvotes: 3
Views: 3002
Reputation: 1888
Importing scala.collection.immutable
solved the problems with collections, for the classOf
problem I found a workaround - using getClass
instead. toInt
problem remains unsolved. There is a workaround though - using the exact code from that definition: java.lang.Integer.parseInt
. I have a feeling that this is also a problem with imports.
Upvotes: 1