当我在一个示例应用程序中调用sbt时,我遇到了NPE(NullPointerException)。
请注意:我们不能使用“play”运行整个应用程序:我们需要能够通过sbt运行它。
C:\apps\playframework\samples\scala\websocket-chat>sbt
java.lang.NullPointerException
at sbt.StringUtilities$.nonEmpty(StringUtilities.scala:14)
at sbt.impl.GroupArtifactID.$percent(DependencyBuilders.scala:50)
at $f01bf36bc7174607fa7f$.$sbtdef(C:\apps\playframework\samples\scala\websocket-chat\project\plugins.sbt:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.Eval$.getValue(Eval.scala:420)
at sbt.compiler.Eval$$anonfun$4.apply(Eval.scala:87)
at sbt.compiler.Eval$$anonfun$4.apply(Eval.scala:87)
at sbt.EvaluateConfigurations$$anonfun$evaluateSetting$1.apply(EvaluateConfigurations.scala:150)
at sbt.EvaluateConfigurations$$anonfun$evaluateSetting$1.apply(EvaluateConfigurations.scala:148)
at sbt.EvaluateConfigurations$$anonfun$flatten$1$$anonfun$apply$5.apply(EvaluateConfigurations.scala:115)
at sbt.EvaluateConfigurations$$anonfun$flatten$1$$anonfun$apply$5.apply(EvaluateConfigurations.scala:115)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
at sbt.EvaluateConfigurations$$anonfun$flatten$1.apply(EvaluateConfigurations.scala:115)
at sbt.EvaluateConfigurations$$anonfun$flatten$1.apply(EvaluateConfigurations.scala:115)
at sbt.EvaluateConfigurations$$anonfun$evaluateSbtFile$1.apply(EvaluateConfigurations.scala:110)
at sbt.EvaluateConfigurations$$anonfun$evaluateSbtFile$1.apply(EvaluateConfigurations.scala:110)
at sbt.Load$.sbt$Load$$loadSettingsFile$1(Load.scala:507)
at sbt.Load$$anonfun$sbt$Load$$memoLoadSettingsFile$1$1.apply(Load.scala:502)
at sbt.Load$$anonfun$sbt$Load$$memoLoadSettingsFile$1$1.apply(Load.scala:501)
at scala.Option.getOrElse(Option.scala:120)
at sbt.Load$.sbt$Load$$memoLoadSettingsFile$1(Load.scala:501)
at sbt.Load$$anonfun$loadSettings$1$2.apply(Load.scala:500)
at sbt.Load$$anonfun$loadSettings$1$2.apply(Load.scala:500)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at sbt.Load$.loadSettings$1(Load.scala:500)
at sbt.Load$.sbt$Load$$expand$1(Load.scala:523)
at sbt.Load$.loadSettings(Load.scala:528)
at sbt.Load$.sbt$Load$$loadSbtFiles$1(Load.scala:464)
at sbt.Load$.defaultLoad$1(Load.scala:475)
编辑 这是项目\plugins.sbt文件
logLevel := Level.Warn
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.0"))
libraryDependencies <+= sbtVersion { sv =>
"org.scala-sbt" % "scripted-plugin" % sv
}
这条代码:
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.0"))
导致以下情况:
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
编辑 更多细节
C:\apps\play\framework>sbt package
"sbt13"
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[info] Loading project definition from C:\apps\play\framework\project
[warn] module not found: play#sbt-plugin;2.2.3
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.2.3/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.2.3/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\S80035683\.ivy2\local\play\sbt-plugin\scala_2.9.2\sbt_0.12\2.2.3\ivys\ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.9.2_0.12/2.2.3/sbt-plugin-2.2.3.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.2.3: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] play:sbt-plugin:2.2.3 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.2.3: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
sbt-plugin
绑定到play版本(不同的play版本将有不同的sbt插件)。通常版本设置为系统属性,但似乎对于您正在使用的play版本存在错误。 - lpiepiora.getOrElse("2.2.3")
这部分,这样就完整了。 - lpiepiora