Reputation: 87
I want to use thread pool in my scala project. It can runs well in my IntelliJ Idea, but it throws exception when I compile the project use maven command line: mvn compile. I have added the dependencies "scala-libray" and "scala-actors", but nothing ever effects. Can you help me?
My code:
import scala.actors.threadpool.Executors
val execService = Executors.newFixedThreadPool(10)
The error:
[ERROR] /project../server/EasyServer.scala:6: error: object actors is not a member of package scala
[ERROR] import scala.actors.threadpool.Executors
[ERROR] ^
[ERROR] /project../server/EasyServer.scala:16: error: not found: value Executors
[ERROR] val execService = Executors.newFixedThreadPool(10)
[ERROR] ^
[ERROR] two errors found
A part of my pom.xml:
<properties>
<scala.version>2.11.6</scala.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-actors</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/.svn/</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- the Maven compiler plugin will compile Java source files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- the Maven Scala plugin will compile Scala source files -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Bind the maven-assembly-plugin to the package phase this will create
a jar file without the storm dependencies suitable for deployment to
a cluster.
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Upvotes: 1
Views: 3090
Reputation: 29538
Starting from 2.11, scala actors are shipped as a separate library :
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-actors</artifactId>
<version>2.11.6</version>
</dependency>
Note that they are also deprecated in favor of Akka : http://docs.scala-lang.org/overviews/core/actors-migration-guide.html
Upvotes: 4