【问题标题】:Libraries not visible to modules after SBT import in IntelliJ在 IntelliJ 中导入 SBT 后,模块对模块不可见
【发布时间】:2016-04-20 22:33:57
【问题描述】:

项目编译并运行良好,但源代码在 IDE 中看不到库。

注意中间,编辑器无法识别来自项目中库或其他模块的导入,尽管您可以看到左侧的库。

我感觉这是因为我对模块系统的工作原理缺乏了解。我从源代码和 build.sbt 开始,并在 IntelliJ(最新版本 15.0.5)中使用了File > New > Project from Existing Sources。 IntelliJ 为项目创建了单独的模块 build、maintestmaintest 似乎无权访问依赖项。

我查看了项目结构,果然,依赖项存在于顶级“tcparser”模块,但不存在于“main”或“test”:

所以我点击右侧的绿色+ 并尝试为test 模块添加库依赖项,但我收到错误消息Module "tcparser" must not contain source root "path to \src\main\java". The root already belongs to module "main",这对我来说毫无意义。

发生了什么,我该如何解决?我并不是特别想将我的项目分成模块,所以如果这是解决方案,我可以摆脱它们。

【问题讨论】:

    标签: scala intellij-idea sbt


    【解决方案1】:

    第一次在 IntelliJ 中打开项目时,需要选择build.sbt 文件,而不是顶层文件夹。然后它应该被正确导入,没有单独的“模块”用于 main 和 test。

    【讨论】:

      猜你喜欢
      • 2016-08-09
      • 1970-01-01
      • 1970-01-01
      • 2017-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多