在示例应用程序中调用sbt时,我得到了一个NPE。
请注意:我们无法使用“播放”运行我们的整体应用:我们需要能够通过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)
答案 0 :(得分:7)
修改project/plugins.sbt
并更改
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % System.getProperty("play.version"))
到
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.2.3"))
您还可以获得更新的Play版本,此问题似乎已修复。
如果需要,您还可以设置系统属性play.version
。
确保您在plugins.sbt
。
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
答案 1 :(得分:1)
这是基于lpiepiora的答案,但是最新的(因为他建议的修复对我不起作用)。我运行最新版本的所有内容(截至2016年4月4日)并使用以下内容获取scala播放示例以构建和运行:
编辑project / plugins.sbt并确保你有这一行:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.3")
明确指定播放版本为2.2.3将正常工作,因为这是样本所针对的。