在Java Maven项目中使用Scala类的编译错误 [英] Compilation error using scala classes in java maven project

查看:639
本文介绍了在Java Maven项目中使用Scala类的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java Maven项目,我为eclipse安装了scala插件,并为我的项目添加了scala性质。现在,我已经编写了一些自定义的Scala Actor和其他一些实用程序类。我在Java代码中使用了这些scala类。在编写代码时,它不会引发任何错误。但是,当我执行maven clean / build时,它会引发如下的编译错误

I have a java maven project , i installed scala plugin for eclipse and added scala nature to my project . Now , i have written some custom scala Actors and some other utility classes .I am using these scala classes in my java code . while writing the code , it doesn't throw any errors .But , when i do maven clean /build , it throws compilation error's like below

11/8/11 10:45:23 AM : [ERROR] ............\Simple.java:[86,10] cannot find symbol
symbol  : variable ExecutorObject
location: class com.ms.scala.Simple
11/8/11 10:45:23 AM : [INFO] 2 errors 
11/8/11 10:45:23 AM : [INFO] -------------------------------------------------------------
11/8/11 10:45:23 AM : Build errors for Project; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project : Compilation failure

Eclipse IDE:helios -3.5,Scala-插件随附的2.9.2

Eclipse IDE : helios -3.5 , Scala - 2.9.2 which comes with the plugin

我想这样做有一个自定义的编译器配置?我也有另一个新手问题

i guess there is a custom compiler configuration for doing this ? i also have an other newbie question

如何直接在Java中启动scala actor并向其发送消息?我所看到的只是act()方法。我想这样做

how do you start scala actor directly in java and send a message to it ? all i can see is the act() method . i want to do this

actor {

CustomActor ! Message

}

在Java中

谢谢您
sanre6

thank you sanre6

推荐答案

在第一部分中,您是否添加了scala编译步骤到您的行家pom?您是否已将 maven-scala-plugin 添加到您的pom?

For the first part, have you added the scala compilation step to your maven pom? Have you added the maven-scala-plugin to your pom?

对于第二部分,正如Mirco所说,没有简单的方法来定义Java中的Actor。您必须在Scala中对其进行定义,但是您可以随后使用Java启动它并向它发送消息。

For the second part, as Mirco says, there is no simple way to define an Actor in Java. You'll have to define it in Scala, but you can then start it and send messages to it in Java.

只需调用 start() 实例,然后您应该可以使用!方法。这将在Java中可用,但称为 $ bang

Simply call start() on the instance, and then you should be able to pass messages to it using the ! method. This will be available in java, but it is called $bang.

这篇关于在Java Maven项目中使用Scala类的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆