简体   繁体   English

不能在Java中使用Scala类

[英]Cannot use Scala class in Java

I believe Scala and Java can use classes from each other. 我相信Scala和Java可以使用彼此的类。

However, I found myself in a situation that my Java class cannot use a Scala class in the same package. 但是,我发现自己的情况是我的Java类不能在同一个包中使用Scala类。

The scala class is defined as: scala类定义为:

class CustomerService extends AbstractCustomerService {

The code trying to use this bit of code is: 试图使用这段代码的代码是:

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

The error I got is: 我得到的错误是:

[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

Can someone give me some hint about this? 有人可以给我一些暗示吗?

Many thanks 非常感谢

根据本文配置你的pom.xmlscala和java源的联合补充

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM