IntelliJ: Command Line is too Long. Shorten command line for… in SBT project

亡梦爱人 提交于 2020-01-03 03:14:10

问题


When I try to run my app, IntelliJ has just started to tell me

"Command Line is too Long. Shorten command line for my_app or also for Application default configuration."

the my_app is a blue link which leads to an "Edit Configuration" window, automatically selecting and highlighting a dropdown for class path shortener. I select the suggested options, but no change.

I have no idea what this means - I'm using Scala, so I'm using a simple object MyObj extends App which takes no parameters at all.

I have tried adding <property name="dynamic.classpath" value="true" /> to the workspace.xml as suggested by other similar questions, but to no avail.

I used to be able to run my programs in my project fine before. But what lengthens a command line? What is being put on the command line at all?


回答1:


Found the fix, this is SBT specific. I believe what is happening is that the libaryDependencies one puts in their build.sbt file actually adds all the jars of those dependencies to the classpath used to run your program.

To fix this, simply add

lazy val scriptClasspath = Seq("*") (the lazy may be optional)

to your build.sbt file. I placed mine above the root val with the library dependencies. Not sure if that's necessary, but shift it around if you're having trouble

What this does, is upon running the program SBT will condense the "long" classpath built by those jars into a jar of its own, and just run that jar, which will kick off all of your dependencies and program.

Check this out for the longer demonstration, as well as other answers



来源:https://stackoverflow.com/questions/49039414/intellij-command-line-is-too-long-shorten-command-line-for-in-sbt-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!