使用 Native sbt Packager 为 windows 打包 Play 应用程序
Packaging Play application for windows using Native sbt Packager
我用 play 制作了一个小型 HTTP 服务器。我现在想通过安装构建一个 windows 版本。我已经在几个月前制作了一个,但我修改了我的应用程序,所以我必须重新安装。但是,如果不更改 sbt 文件中的所有内容,它会失败...
这里是我用于构建安装的命令:
activator windows:packageBin
这是我在安装后启动应用程序时遇到的错误:
Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration$.load(Configuration.scala:66)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration.apply(Application.scala:76)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration.apply(Application.scala:76)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.WithDefaultConfiguration$class.initialConfiguration(Application.scala:75)
at play.api.DefaultApplication.initialConfiguration$lzycompute(Application.scala:402)
at play.api.DefaultApplication.initialConfiguration(Application.scala:402)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalClass(Application.scala:25)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass(Application.scala:402)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:31)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:402)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance.apply(Application.scala:54)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance.apply(Application.scala:53)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:52)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:402)
at play.api.WithDefaultGlobal$class.global(Application.scala:68)
at play.api.DefaultApplication.global(Application.scala:402)
at play.api.WithDefaultConfiguration$class.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:82)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:402)
at play.api.WithDefaultConfiguration$class.configuration(Application.scala:84)
at play.api.DefaultApplication.configuration(Application.scala:402)
at play.api.Application$class.$init$(Application.scala:274)
at play.api.DefaultApplication.<init>(Application.scala:406)
at play.core.StaticApplication.<init>(ApplicationProvider.scala:53)
at play.core.server.NettyServer$.createServer(NettyServer.scala:253)
at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:289)
at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:284)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:284)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: com.typesafe.config.ConfigException$IO: application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties
at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:235)
at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:128)
at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:811)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:113)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:136)
at com.typesafe.config.ConfigFactory.loadDefaultConfig(ConfigFactory.java:228)
at com.typesafe.config.ConfigFactory.access[=12=]0(ConfigFactory.java:38)
at com.typesafe.config.ConfigFactory.call(ConfigFactory.java:378)
at com.typesafe.config.ConfigFactory.call(ConfigFactory.java:375)
at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:58)
at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:86)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:375)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:299)
at play.api.Configuration$.dontAllowMissingConfig$lzycompute(Configuration.scala:29)
at play.api.Configuration$.dontAllowMissingConfig(Configuration.scala:29)
at play.api.Configuration$.load(Configuration.scala:64)
... 34 more
Caused by: com.typesafe.config.ConfigException$IO: application.conf: java.io.IOException: resource not found on classpath: application.conf
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:183)
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:170)
at com.typesafe.config.impl.Parseable.parse(Parseable.java:148)
at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:185)
... 49 more
Caused by: java.io.IOException: resource not found on classpath: application.conf
at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:579)
at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:554)
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:176)
... 52 more
这是我的 sbt 文件:
name := """IDTabDriver"""
name in Windows := "IdTabDriver"
packageSummary in Windows := "IdTabDriver"
packageDescription in Windows := "IdTabDriver"
maintainer in Windows := "My Company"
organization := "My Company"
version := "1.0.0.1"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
cache,
javaWs,
"commons-configuration" % "commons-configuration" % "1.10",
"org.rxtx" % "rxtxcomm" % "2.0-7pre1"
)
如果有人有想法,我已经尝试了很多我找不到解决方案的方法
如果您只是使用 Play 附带的功能,那么您只需 运行 在 SBT 控制台中 dist
。
然后在 target/universal
中查找压缩文件。当您解压缩 运行 .bat
文件夹中的 bin
文件时。
我也遇到了同样的错误,抱怨在类路径上找不到资源 application.conf。这可能与 know bug in sbt-play plugin. Until the recent bug fix is released, try adding the following line to your build.sbt as a workaround as suggested by the Play development team.
有关
PlayKeys.externalizeResources := false
这对我有用。
我用 play 制作了一个小型 HTTP 服务器。我现在想通过安装构建一个 windows 版本。我已经在几个月前制作了一个,但我修改了我的应用程序,所以我必须重新安装。但是,如果不更改 sbt 文件中的所有内容,它会失败...
这里是我用于构建安装的命令:
activator windows:packageBin
这是我在安装后启动应用程序时遇到的错误:
Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration$.load(Configuration.scala:66)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration.apply(Application.scala:76)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration.apply(Application.scala:76)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.WithDefaultConfiguration$class.initialConfiguration(Application.scala:75)
at play.api.DefaultApplication.initialConfiguration$lzycompute(Application.scala:402)
at play.api.DefaultApplication.initialConfiguration(Application.scala:402)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalClass(Application.scala:25)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass(Application.scala:402)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:31)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:402)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance.apply(Application.scala:54)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance.apply(Application.scala:53)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:52)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:402)
at play.api.WithDefaultGlobal$class.global(Application.scala:68)
at play.api.DefaultApplication.global(Application.scala:402)
at play.api.WithDefaultConfiguration$class.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:82)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration$lzycompute(Application.scala:402)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:402)
at play.api.WithDefaultConfiguration$class.configuration(Application.scala:84)
at play.api.DefaultApplication.configuration(Application.scala:402)
at play.api.Application$class.$init$(Application.scala:274)
at play.api.DefaultApplication.<init>(Application.scala:406)
at play.core.StaticApplication.<init>(ApplicationProvider.scala:53)
at play.core.server.NettyServer$.createServer(NettyServer.scala:253)
at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:289)
at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:284)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:284)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: com.typesafe.config.ConfigException$IO: application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties
at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:235)
at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:128)
at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:811)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:113)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:136)
at com.typesafe.config.ConfigFactory.loadDefaultConfig(ConfigFactory.java:228)
at com.typesafe.config.ConfigFactory.access[=12=]0(ConfigFactory.java:38)
at com.typesafe.config.ConfigFactory.call(ConfigFactory.java:378)
at com.typesafe.config.ConfigFactory.call(ConfigFactory.java:375)
at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:58)
at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:86)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:375)
at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:299)
at play.api.Configuration$.dontAllowMissingConfig$lzycompute(Configuration.scala:29)
at play.api.Configuration$.dontAllowMissingConfig(Configuration.scala:29)
at play.api.Configuration$.load(Configuration.scala:64)
... 34 more
Caused by: com.typesafe.config.ConfigException$IO: application.conf: java.io.IOException: resource not found on classpath: application.conf
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:183)
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:170)
at com.typesafe.config.impl.Parseable.parse(Parseable.java:148)
at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:185)
... 49 more
Caused by: java.io.IOException: resource not found on classpath: application.conf
at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:579)
at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:554)
at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:176)
... 52 more
这是我的 sbt 文件:
name := """IDTabDriver"""
name in Windows := "IdTabDriver"
packageSummary in Windows := "IdTabDriver"
packageDescription in Windows := "IdTabDriver"
maintainer in Windows := "My Company"
organization := "My Company"
version := "1.0.0.1"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
cache,
javaWs,
"commons-configuration" % "commons-configuration" % "1.10",
"org.rxtx" % "rxtxcomm" % "2.0-7pre1"
)
如果有人有想法,我已经尝试了很多我找不到解决方案的方法
如果您只是使用 Play 附带的功能,那么您只需 运行 在 SBT 控制台中 dist
。
然后在 target/universal
中查找压缩文件。当您解压缩 运行 .bat
文件夹中的 bin
文件时。
我也遇到了同样的错误,抱怨在类路径上找不到资源 application.conf。这可能与 know bug in sbt-play plugin. Until the recent bug fix is released, try adding the following line to your build.sbt as a workaround as suggested by the Play development team.
有关PlayKeys.externalizeResources := false
这对我有用。