scala IntelliJ 无法解析 build.sbt 中的符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34245991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 07:51:59  来源:igfitidea点击:

IntelliJ cannot resolve symbol in build.sbt

scalaintellij-ideasbt

提问by CodeShaman

IntelliJ IDEA 15 is reporting an unresolved symbol for my project definition in my build.sbtfile

IntelliJ IDEA 15 在我的build.sbt文件中报告我的项目定义的未解析符号

lazy val root = (project in file(".")).enablePlugins(PlayScala)

It's reporting an error with projectand in.

它报告了一个错误projectin

Cannot resolve symbol project.
Cannot resolve symbol in.

Everything else resolves perfectly and the project is otherwise all set up, sbt builds fine, activator runs fine.

其他一切都完美解决,项目其他方面都设置好了,sbt 构建良好,激活器运行良好。

采纳答案by Fabszn

To fix this issue, I imported: import sbt.projecton top of my build.sbt

为了解决这个问题,我导入了:import sbt.project在我的之上build.sbt

I am working with IntelliJ IDEA 16 EAP

我正在使用 IntelliJ IDEA 16 EAP

回答by CodeShaman

I looked on jetbrains' error tracker and found this is a known bug.

我查看了 jetbrains 的错误跟踪器,发现这是一个已知错误。

"Cannot resolve symbol project" in build.sbt

build.sbt 中的“无法解析符号项目”

https://youtrack.jetbrains.com/issue/SCL-9512

https://youtrack.jetbrains.com/issue/SCL-9512

回答by Ruurtjan Pul

In my case, after upgrading Intellij forgot that the project was a Scala project.

就我而言,升级 Intellij 后忘记了该项目是 Scala 项目。

Delete .idea/and import the project to fix this.

删除.idea/并导入项目以解决此问题。

回答by Matt Klein

This happened to me when when the "external library" referenced was a different version than the one stated in the build.sbtfile. Specifically:

当引用的“外部库”与build.sbt文件中所述的版本不同时,这发生在我身上。具体来说:

External Libraries -> SBT: org.scala-lang:scala-library:2.12.1

外部库 -> SBT: org.scala-lang:scala-library:2.12.1

build.sbt -> scalaVersion := "2.12.2"

build.sbt -> scalaVersion := "2.12.2"