将现有sbt项目导入IntelliJ

时间:2018-02-02 08:07:02

标签: scala intellij-idea playframework sbt

我有一个项目,我正在使用intellJ。前段时间我删除了该项目;现在我想再次参与这个项目。但是,在克隆项目后,我无法将项目导入Intellj 2017.2.6。我还安装了最新的Scala插件。

这是日志:

[info] Loading settings from plugins.sbt,scaffold.sbt ...
[info] Loading project definition from C:\Users\Lisa\repositories\Centuries\project
[info] Loading settings from build.sbt ...
[info] Set current project to play-java-starter-example (in build file:/C:/Users/Lisa/repositories/Centuries/)
[info] sbt server started at local:sbt-server-32d2c5673d7428dec3ce
[play-java-starter-example] $
[info] Defining Global / sbtStructureOptions, Global / sbtStructureOutputFile, shellPrompt
[info] The new values will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to play-java-starter-example (in build file:/C:/Users/Lisa/repositories/Centuries/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks from C:/Users/Lisa/.IntelliJIdea2017.2/config/plugins/Scala/launcher/sbt-structure-1.1.jar
[error] java.lang.ClassNotFoundException: org.jetbrains.sbt.CreateTasks$
[error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error]     at java.lang.Class.forName0(Native Method)
[error]     at java.lang.Class.forName(Class.java:348)
[error]     at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:20)
[error]     at sbt.BasicCommands$.$anonfun$call$5(BasicCommands.scala:203)
[error]     at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error]     at scala.collection.immutable.List.foreach(List.scala:389)
[error]     at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error]     at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error]     at scala.collection.immutable.List.map(List.scala:295)
[error]     at sbt.BasicCommands$.$anonfun$call$2(BasicCommands.scala:203)
[error]     at sbt.Command$.$anonfun$applyEffect$4(Command.scala:134)
[error]     at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:153)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:136)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error]     at sbt.State$$anon$1.process(State.scala:248)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:136)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:136)
[error]     at sbt.MainLoop$.run(MainLoop.scala:129)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:107)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:101)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:57)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:42)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:34)
[error]     at sbt.StandardMain$.runManaged(Main.scala:113)
[error]     at sbt.xMain.run(Main.scala:76)
[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:41)
[error]     at xsbt.boot.Boot$.main(Boot.scala:17)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.ClassNotFoundException: org.jetbrains.sbt.CreateTasks$
[error] Use 'last' for the full log.
[info] shutting down server
[INFO] [02/02/2018 08:48:16.063] [Thread-3] [CoordinatedShutdown(akka://sbt-web)] Starting coordinated shutdown from JVM shutdown hook
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0

2 个答案:

答案 0 :(得分:1)

执行以下步骤,看看它是否解决了您的问题:

  1. 重新启动/关闭IntellJ :您可以毫无问题地执行sbt clean compile吗?如果是这样,那就是IntellJ问题,所以首先关闭/重启IntellJ。

  2. 删除.idea文件:首先确定将文件夹复制/粘贴到新路径。在新文件夹中删除.idea文件(Intellj使用的生成文件)。

  3. 导入项目:在intellJ中转到File > open并在新文件夹中打开项目,然后选择自动导入'。确保您的scala和sbt版本与build.sbt相同。

  4. 使Cach无效 e:转到File > Invalidate Cache / Restarts。当我在基于Gradle的项目中工作时,这也解决了我的问题。

答案 1 :(得分:1)

您的项目正在使用sbt 1.1,并且有一个错误阻止在IntelliJ 2017.2中导入。升级到IntelliJ / Scala 2017.3.11或更高版本应该修复它。