由于缺少 Ivy 模块,无法创建 IntelliJ Scala 项目

Posted

技术标签:

【中文标题】由于缺少 Ivy 模块,无法创建 IntelliJ Scala 项目【英文标题】:Cannot Create IntelliJ Scala Project Due to Missing Ivy Module 【发布时间】:2019-10-22 03:59:33 【问题描述】:

我正在使用 IntelliJ 社区 2019.1。我正在尝试通过 SBT 创建一个新的 Scala 项目;但是,当项目尝试从 SBT 构建和转储项目结构时,我收到以下错误。 SBT 版本 1.2.7;斯卡拉版本 2.11.12; JDK 1.8.0_202,

Error while importing sbt project:
[error] java.lang.NoClassDefFoundError: org/apache/ivy/core/module/id/ModuleRevisionId
[error]     at sbt.Keys$.<init>(Keys.scala:439)
[error]     at sbt.Keys$.<clinit>(Keys.scala)
[error]     at sbt.Cross$.$anonfun$requireSession$1(Cross.scala:78)
[error]     at sbt.Command$.$anonfun$applyEffect$3(Command.scala:142)
[error]     at sbt.Command$.$anonfun$combine$2(Command.scala:147)
[error]     at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:233)
[error]     at scala.collection.immutable.List.foreach(List.scala:388)
[error]     at scala.collection.TraversableLike.map(TraversableLike.scala:233)
[error]     at scala.collection.TraversableLike.map$(TraversableLike.scala:226)
[error]     at scala.collection.immutable.List.map(List.scala:294)
[error]     at sbt.Command$.$anonfun$combine$1(Command.scala:147)
[error]     at sbt.Command$.process(Command.scala:180)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:151)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:246)
[error]     at sbt.State$$anon$1.process(State.scala:250)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:139)
[error]     at sbt.MainLoop$.run(MainLoop.scala:132)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]     at sbt.StandardMain$.runManaged(Main.scala:138)
[error]     at sbt.xMain.run(Main.scala:89)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]     at xsbt.boot.Boot$.main(Boot.scala:18)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] Caused by: java.lang.ClassNotFoundException: org.apache.ivy.core.module.id.ModuleRevisionId
[error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error]     at sbt.Keys$.<init>(Keys.scala:439)
[error]     at sbt.Keys$.<clinit>(Keys.scala)
[error]     at sbt.Cross$.$anonfun$requireSession$1(Cross.scala:78)
[error]     at sbt.Command$.$anonfun$applyEffect$3(Command.scala:142)
[error]     at sbt.Command$.$anonfun$combine$2(Command.scala:147)
[error]     at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:233)
[error]     at scala.collection.immutable.List.foreach(List.scala:388)
[error]     at scala.collection.TraversableLike.map(TraversableLike.scala:233)
[error]     at scala.collection.TraversableLike.map$(TraversableLike.scala:226)
[error]     at scala.collection.immutable.List.map(List.scala:294)
[error]     at sbt.Command$.$anonfun$combine$1(Command.scala:147)
[error]     at sbt.Command$.process(Command.scala:180)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:151)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:246)
[error]     at sbt.State$$anon$1.process(State.scala:250)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:139)
[error]     at sbt.MainLoop$.run(MainLoop.scala:132)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]     at sbt.StandardMain$.runManaged(Main.scala:138)
[error]     at sbt.xMain.run(Main.scala:89)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]     at xsbt.boot.Boot$.main(Boot.scala:18)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.NoClassDefFoundError: org/apache/ivy/core/module/id/ModuleRevisionId

我尝试重新安装 IntelliJ,从 Apache 添加 apache ivy jars(并将它们导入 build.sbt!),重新打包,重新组装并重新启动 IDE。其中没有一个可以创建新项目。

非常感谢您在解决错误方面的任何帮助。谢谢!

【问题讨论】:

【参考方案1】:

经过大量的反复试验、Google 搜索和挫折,我终于找到并纠正了我遇到的问题!

存在 sbt 版本冲突;我试图使用 sbt 1.2.7,但是当我升级到 sbt 1.2.8 时,一切都按预期工作。我能够通过 sbt 创建新项目,并构建从我公司的企业 GitHub 克隆的现有项目。我希望这可以帮助其他人节省数小时的工作时间和挫败感!

【讨论】:

以上是关于由于缺少 Ivy 模块,无法创建 IntelliJ Scala 项目的主要内容,如果未能解决你的问题,请参考以下文章

具有 ivy 依赖项的 Eclipse 部署程序集失败

无法使用 ivy.xml 解决依赖关系,找不到模块错误

如何在 IntelliJ IDEA 中改变 Ivy 的家

在 IntelliJ/Grails 中更改 Ivy 缓存位置

由于缺少实际文件夹,已安装 python 模块但无法导入 - 怎么办?

在 .ivy2 文件中找不到在线依赖,Intellij Idea 也没有找到