简体   繁体   English

IntelliJ SBT项目无法解析SBT符号

[英]IntelliJ SBT project cannot resolve SBT symbols

I'm banging my head against the wall on this one. 我正在把头撞在墙上。

Trying to open a cloned git SBT project at work. 尝试在工作中打开一个克隆的git SBT项目。 It is a combined Java and Scala Play project, with scala 2.11.1, SBT 0.13.6, and Play 2.5. 它是Java和Scala Play的组合项目,具有scala 2.11.1,SBT 0.13.6和Play 2.5。

I use IntelliJ to import project from the cloned repo, with JDK 1.8, and all download and SBT checkboxes checked, and then run either SBT refresh, or reload from SBT shell. 我使用IntelliJ从克隆的仓库中导入项目,并已选中JDK 1.8,并选中了所有下载和SBT复选框,然后运行SBT刷新或从SBT Shell重新加载。

After doing so, all SBT and Play code on both build.sbt and plugins.sbt is painted red, as in "cannot resolve symbol". 这样做之后,build.sbt和plugins.sbt上的所有SBT和Play代码都涂成红色,如“无法解析符号”所示。

Looking at Intellij poroject structure, I have JDK1.8 on the SDK tab, and scala-sdk-2.11 on the Global Libraries tab. 查看Intellij的结构,在SDK选项卡上有JDK1.8,在Global Libraries选项卡上有scala-sdk-2.11。 SBT and Scala plugins are installed and enabled. SBT和Scala插件已安装并启用。

SBT refresh fails on the following Play dependency, which could be the reason for the above symptom, since the SBT build does not complete: 由于以下SBT生成未完成,因此以下播放依赖项上的SBT刷新失败,这可能是上述症状的原因:

unresolved dependency: com.typesafe.play.plugins#play-statsd_2.11;2.3.0: not found 未解决的依存关系:com.typesafe.play.plugins#play-statsd_2.11; 2.3.0:找不到

The dependency does exist: http://dl.bintray.com/typesafe/maven-releases/com/typesafe/play/plugins/play-statsd_2.11/2.3.0/ 确实存在依赖项: http : //dl.bintray.com/typesafe/maven-releases/com/typesafe/play/plugins/play-statsd_2.11/2.3.0/

What am I doing wrong? 我究竟做错了什么?

在此处输入图片说明

Turns out the problem is on the typesafe side, not on my env. 原来问题出在类型安全方面,而不是我的环境。 All typesafe dependencies on the project are resolved as expected, except for play-statsd. 除play-statsd之外,所有对项目的类型安全依赖项均按预期解决。

I manually added this dependency to my ivy cache, and now everything works fine. 我手动将此依赖项添加到我的常春藤缓存中,现在一切正常。 It was a hard one to isolate, because apparently everybody here already have the dependency on their caches, so seems like their updates work well... 这很难隔离,因为显然这里的每个人都已经依赖于他们的缓存,因此看起来他们的更新效果很好...

If anyone has the same problem, fetch the dependency from the bintray repository , and manually add it to your ivy cache, eg 如果有人遇到相同的问题,请从bintray存储库中获取依赖 ,然后将其手动添加到您的ivy缓存中,例如

~/.ivy2/cache/com.typesafe.play.plugins/play-statsd_2.11 〜/ .ivy2 /缓存/ com.typesafe.play.plugins /播放statsd_2.11

The github play-plugins repository has been archived, so I can't open an issue, and don'y know if anyone will take care of it anyway. github play-plugins存储库已存档,所以我无法打开问题,也不知道是否有人会照顾它。

Unresolved dependency error usually related with Scala version that you are using. 未解决的依赖项错误通常与您使用的Scala版本有关。

Here is Play 2.3.x documentation. 这是Play 2.3.x文档。 https://www.playframework.com/documentation/2.3.x/Migration22#Update-Scala-version https://www.playframework.com/documentation/2.3.x/Migration22#Update-Scala-version

If you are able to use Play 2.7.x, your issue will be fixed. 如果您能够使用Play 2.7.x,则问题将得到解决。

您能否按如下所示在build.sbt中添加Play StatsD依赖项并检查一次。

"com.typesafe.play.plugins" %% "play-statsd" % "2.3.0"

您应该添加Maven-releases解析器:

resolvers += "Typesafe Resolver" at "http://repo.typesafe.com/typesafe/maven-releases/"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM