How to force IntelliJ IDEA to reload dependencies

2019-01-13 04:06发布

问题:

I'm using IntelliJ IDEA 13 (Community Edition) with the Scala plugin.

My initial import of an existing Scala project with a build.sbt worked fine. The library dependencies were picked up by IDEA. Additional dependencies added after the initial import were not picked up, although I had checked the auto-import option.

How can I force IDEA to reload the dependencies from build.sbt?

回答1:

You can force SBT to reload changes: Open SBT toolwindow (on the right side of IDE) and press refresh button.

If you use auto-import feature you need to save your file to force auto-refresh.



回答2:

IF plugin gets 'stuck' it helps to invalidate cache (under file menu) and restart intellij.



回答3:

As of 7 Dec, 2013, the issue is solved. You need to update the Scala plugin in IntelliJ IDEA (this applies to both community and ultimate editions).

This is the link to the issue opened on JetBrains developer community web site: http://devnet.jetbrains.com/thread/451395



回答4:

This may be due to a broken publication of org.jetbrains:sbt-structure:latest.integration that occurred tonight, about 4 or 5 hours ago. Given that your post is 4 hours old ...

You can see the ivy activity in idea.log (~/Library/Logs/IntelliJIdea13 or ~/Library/Logs/IdeaIC13 on OSX).

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.jetbrains#sbt-structure;latest.integration: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          org.jetbrains:sbt-structure:latest.integration (sbtVersion=0.13, scalaVersion=2.10)

I have opened a ticket at JetBrains.



回答5:

Ticket for broken plublication of sbt.jetbrains is resolved. Updating scala plugin will fix this issue Ticket : http://devnet.jetbrains.com/thread/451395



回答6:

Perhaps this working only for some kind of projects, but in my case,

on the Library side, I do in sbt: publishLocal

on the Client side where the Library goes into, I click the menu item Build -> Build (Ctrl-F9), and sometimes, when open Files or Intellisens are not yet current, I do Ctrl-Alt-Y (Menu item File -> Synchronize) to get the file reflecting the refreshed code base.

Not having to refresh all sbt projects is faster for me.