【问题标题】:Cannot use Scala class in Java无法在 Java 中使用 Scala 类
【发布时间】:2012-02-21 15:05:44
【问题描述】:

我相信 Scala 和 Java 可以互相使用类。

但是,我发现自己的 Java 类无法在同一个包中使用 Scala 类。

scala 类定义为:

class CustomerService extends AbstractCustomerService {

尝试使用这段代码的代码是:

public Deployer() {
        singletons.add(new CustomerService());
}

我得到的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3:compile (default-compile) on project orderservice: Compilation failure
[ERROR] \devel\raven\services\orderservice\service\src\main\scala\com\mxyy\orderservice\customer\Deployer.java:[12,31] cannot find symbol
[ERROR] symbol  : class CustomerService
[ERROR] location: class com.mxyy.orderservice.customer.Deployer

有人可以给我一些提示吗?

非常感谢

【问题讨论】:

标签: java scala maven scala-java-interop


【解决方案1】:

根据这篇文章配置你的pom.xmljoint compliation of scala and java sources

【讨论】:

  • 这应该在 maven Scala 原型中
猜你喜欢
  • 2012-12-06
  • 2013-10-21
  • 1970-01-01
  • 2020-07-06
  • 1970-01-01
  • 1970-01-01
  • 2011-09-01
  • 2012-01-08
  • 2017-05-31
相关资源
最近更新 更多