Eclipse scala.object无法解析 [英] Eclipse scala.object cannot be resolved

查看:484
本文介绍了Eclipse scala.object无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Eclipse在Java中编写Kafka生产者和消费者代码。
我已经下载了Kafka jar文件并作为外部Jar文件加载。它解决了依赖问题。

I am trying to write Kafka producer and consumer code in Java using Eclipse. I am have downloaded the Kafka jar file and loaded as external Jar file. And it solved the dependency problem.

但是,始终存在未解决的错误,并且消息如下所示:

However, there is always a unresolved error and the message looks like below:

Multiple markers at this line
- The type scala.Product cannot be resolved. It is indirectly referenced from required .class files
- The type scala.Serializable cannot be resolved. It is indirectly referenced from required .class 
 files

我真的不知道是什么继续以及如何解决该错误。谢谢。

I really don't know what is going on and how to fix that error. Thanks.

推荐答案

更新4/26/2018

您似乎需要在 Eclipse 项目的类路径中包含 Scala 运行时库。

It appears that you need to have the Scala runtime library in your Eclipse project's classpath.

如果您是使用 Maven (或其他一些基于存储库的构建工具 - 强烈推荐),然后添加 Kafka 作为依赖项应该使它自动下载相应的 Scala 运行时库并将其包含在项目的类路径中。例如,

If you're using Maven (or some other repository-based build tool—highly recommended), then adding Kafka as a dependency should cause it to automatically download the corresponding Scala runtime library and include it on your project's classpath. For example,

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.12</artifactId>
    <version>1.1.0</version>
</dependency>

将导致 Maven 下载的2.12.4版本Scala 运行时库。

否则,您可以安装Scala(参见 http://scala-lang.org/ )并手动将已安装的scala-library.jar添加到项目的类路径中。但是,您应该注意 Scala 次要版本(2.10.x,2.11.x,2.12.x等)彼此不是二进制兼容的,因此您应该下载最新的错误修复用于构建 Kafka 版本的次要版本的版本。 (此次要版本附加到 Kafka 工件的名称,例如kafka_2.12需要 Scala 2.12.x运行时库版本。)

Otherwise, you can install Scala (see http://scala-lang.org/) and add the installed scala-library.jar to your project's classpath manually. However, you should note that Scala minor releases (2.10.x, 2.11.x, 2.12.x, etc.) are not binary compatible with each other, so you should download the most recent bug-fix version of the minor release used to build your version of Kafka. (This minor version is appended to the name of the Kafka artifact, e.g. kafka_2.12 requires a Scala 2.12.x runtime library version.)

这篇关于Eclipse scala.object无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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