IntelliJ无法编译:scala.collection.Iterable的类文件

时间:2018-07-14 14:56:35

标签: java intellij-idea akka

我正在学习akka并尝试实现一个Actor。但是我无法在IntelliJ中编译以下代码。编译代码时,它将引发以下错误。

  

错误:java:com.sun.tools.javac.code.Symbol $ CompletionFailure:scala.collection.Iterable的类文件

悬停$Props.props()时显示错误

  

无法访问scala.Product

package com.tuitorial.akka.main;

import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;

public class AkkaCounterMain {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("HelloAkka");

        Counter c = new Counter();

        ActorRef countIncreamenter = system.actorFor(CountIncreamenter.props(c), "countIncreamentor");

        countIncreamenter.tell(new CountIncreamenter.Message(), ActorRef.noSender());

    }

    public static class CountIncreamenter extends AbstractActor {

        static public Props props(Counter counter) {
            return Props.create(CountIncreamenter.class, () -> new CountIncreamenter(counter));
        }

        private Counter counter;

        public CountIncreamenter(Counter counter) {
            this.counter = counter;
        }

        @Override
        public Receive createReceive() {
            return receiveBuilder()
                    .match(Message.class, m -> {
                        counter.increament();
                    })
                    .build();
        }

        // protocol
        public static class Message {

        }
    }
}

我验证了scala-library:2.12.6在“外部库”下是否可用。我正在使用gradle,以下是我的gradle文件。我的假设是scala库不在类路径上,但是我无法验证。

plugins {
    id 'java'
}

group 'com.tutorial.akka'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'com.typesafe.akka', name: 'akka-actor_2.12', version: '2.5.14'
    testCompile group: 'com.typesafe.akka', name: 'akka-testkit_2.12', version: '2.5.14'
}

0 个答案:

没有答案