我启动时SBT运行失败

时间:2015-12-07 16:35:24

标签: scala sbt

当我运行命令std::tuple时,我遇到了一些问题:

sbt run

当我谷歌它时,我遇到的大多数错误都有一个问题,但是对于这种错误,不知道如何解决这个问题。

我的档案$ sbt run java.lang.NoSuchMethodError: com.typesafe.config.ConfigFactory.defaultApplication(Lcom/typesafe/config/ConfigParseOptions;)Lcom/typesafe/config/Config; at play.api.Configuration$$anonfun$3.apply(Configuration.scala:75) at play.api.Configuration$$anonfun$3.apply(Configuration.scala:71) at scala.Option.getOrElse(Option.scala:121) at play.api.Configuration$.load(Configuration.scala:71) at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:203) at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61) at play.utils.Threads$.withContextClassLoader(Threads.scala:21) at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60) at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50) at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at play.runsupport.Reloader$.startDevMode(Reloader.scala:207) at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:73) at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:73) at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:99) at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:52) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

build.sbt

有人看到这个问题有一个问题吗?

使用import play.routes.compiler.InjectedRoutesGenerator import play.sbt.PlayScala version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayScala) scalaVersion := "2.11.6" libraryDependencies ++= Seq( cache, ws, filters, "com.typesafe" % "config" % "1.0.0", "org.reactivemongo" %% "play2-reactivemongo" % "0.11.7.play24", "com.amazonaws" % "aws-java-sdk" % "1.10.12", "org.webjars" %% "webjars-play" % "2.4.0-1", "org.webjars" % "bootstrap" % "3.3.5", "org.webjars" % "angularjs" % "1.4.7", "org.webjars" % "angular-ui-bootstrap" % "0.14.3", "org.webjars" % "angular-ui-router" % "0.2.15" ) resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/" resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases" resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/" // Play provides two styles of routers, one expects its actions to be injected, the // other, legacy style, accesses its actions statically. routesGenerator := InjectedRoutesGenerator 更新:

application.conf

# This is the main configuration file for the application. # ~~~~~ # Secret key # ~~~~~ # The secret key is used to secure cryptographics functions. # # This must be changed for production, but we recommend not changing it in this file. # # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. play.crypto.secret = "changeme" # The application languages # ~~~~~ play.i18n.langs = [ "en" ] # Router # ~~~~~ # Define the Router object to use for this application. # This router will be looked up first when the application is starting up, # so make sure this is the entry point. # Furthermore, it's assumed your route file is named properly. # So for an application router like `my.application.Router`, # you may need to define a router file `conf/my.application.routes`. # Default to Routes in the root package (and conf/routes) # play.http.router = my.application.Routes # Database configuration # ~~~~~ # You can declare as many datasources as you want. # By convention, the default datasource is named `default` # # db.default.driver=org.h2.Driver # db.default.url="jdbc:h2:mem:play" # db.default.username=sa # db.default.password="" # Evolutions # ~~~~~ # You can disable evolutions if needed # play.evolutions.enabled=false # You can disable evolutions for a specific datasource if necessary # play.evolutions.db.default.enabled=false play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"

project/plugins.sbt

3 个答案:

答案 0 :(得分:1)

"com.typesafe" % "config" % "1.0.0",更新为1.3.0

根据github,错过的方法出现在1.3.0 <{1}}的{​​{1}}版本中

https://github.com/typesafehub/config/blob/master/config/src/main/java/com/typesafe/config/ConfigFactory.java

ConfigFactory

答案 1 :(得分:1)

对于遇到此问题的人来说,解决问题的方法是将config-1.3.0.jar放入lib文件夹。

答案 2 :(得分:0)

如果将一些播放库放入提供的环境类路径中(与组装的胖jar一样),也会发生同样的错误。例如,Flink 1.3.2有一个较旧的com.typesafe.config库,与Play 2.5或更远不兼容。

要解决的方法是通过按照sbt-assembly.

中的说明对库进行着色