Intellij编译失败:“已经定义为” [英] Intellij compile failures: "is already defined as"

查看:414
本文介绍了Intellij编译失败:“已经定义为”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个scala项目,在命令行中使用SBT时可以编译,运行和测试。但是,在intellij中构建项目时,似乎项目中的每个类在事件日志中都有此错误,导致构建失败:

I've got a scala project that compiles, runs and tests fine when using SBT from the command line. However, when building the project in intellij, it seems every class in the project has this error in the event log, causing the build to fail:

SendCommandToService is already defined as case class SendCommandToService
case class SendCommandToService(service: String, commandName: String, keys: Array[String], values: Array[String])
       ^


推荐答案

这意味着有两个编译的类具有相同的包和类名在你的类路径中。一个由sbt编译,一个由IntelliJ编译。

It means there are two compiled classes with identical package and class name found in your classpath. One compiled by sbt, one compiled by IntelliJ.

以下其中一项应该可以解决问题:

One of the following should be able to solve the issue:


  1. 试试使用 sbt-idea 生成IntelliJ .iml文件,而不是直接导入。

  2. 在使用IntelliJ重建时点击构建 - >重建在IntelliJ

  3. 之前sbt clean,确保sbt没有运行

  1. try to generate IntelliJ .iml file with sbt-idea rather than import directly.
  2. sbt clean before click Build -> Rebuild in IntelliJ
  3. when rebuilding with IntelliJ, make sure sbt is not running

这篇关于Intellij编译失败:“已经定义为”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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