我正在使用Play网络应用程序,我希望能够使用sbt程序集将其部署为胖罐。在调试中运行应用程序时,我可以识别guice库,因为它已添加到我的build.sbt文件中libraryDependencies += guice
。我已经创建了我的sbt程序集MergeStrategy配置并运行了sbt程序集并成功编译了该项目的jar文件,但是当我尝试运行jar时,我在控制台中得到以下异常:
Oops, cannot start the server.
java.lang.RuntimeException: No application loader is configured. Please
configure an application loader either using the play.application.loader
configuration property, or by depending on a module that configures one. You
can add the Guice support module by adding "libraryDependencies += guice" to
your build.sbt.
at scala.sys.package$.error(package.scala:27)
at play.api.ApplicationLoader$.play$api$ApplicationLoader$$loaderNotFound(ApplicationLoader.scala:44)
at play.api.ApplicationLoader$.apply(ApplicationLoader.scala:70)
at play.core.server.ProdServerStart$.start(ProdServerStart.scala:50)
at play.core.server.ProdServerStart$.main(ProdServerStart.scala:25)
at play.core.server.ProdServerStart.main(ProdServerStart.scala)
这是我的build.sbt文件:
name := """Product-Inventory"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.12.3"
//libraryDependencies += Defaults.sbtPluginExtra("com.eed3si9n" % "sbt-assembly" % "0.7.4", "0.12.0-M2", "2.9.1")
// https://mvnrepository.com/artifact/net.ruippeixotog/scala-scraper
libraryDependencies += "net.ruippeixotog" %% "scala-scraper" % "2.0.0"
libraryDependencies += guice //GUICE IS ADDED HERE
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.7"
libraryDependencies += jdbc
libraryDependencies += "postgresql" % "postgresql" % "9.1-901.jdbc4"
// Adds additional packages into Twirl
//TwirlKeys.templateImports += "com.example.controllers._"
// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "com.example.binders._"
mainClass in assembly := Some("play.core.server.ProdServerStart")
fullClasspath in assembly +=
Attributed.blank(PlayKeys.playPackageAssets.value)
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case referenceOverrides if referenceOverrides.contains("reference-
overrides.conf") => MergeStrategy.concat
case PathList("reference-overrides.conf") => MergeStrategy.concat
case x => {
MergeStrategy.first
}
}
由于我已经添加了guice,我不确定发生了什么或如何解决这个问题。这可能是由于MergeStrategy不正确造成的?或者是别的什么?下面我还包括合并的文件列表和适用的合并策略,以防有任何帮助。
[info] Merging files...
[warn] Merging 'META-INF\CHANGES' with strategy 'discard'
[warn] Merging 'META-INF\COPYRIGHT.html' with strategy 'discard'
[warn] Merging 'META-INF\DEPENDENCIES' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_commons-codec-1.10.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_commons-io-2.5.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_commons-lang3-3.6.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_commons-logging-1.2.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_guice-4.1.0' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_guice-assistedinject-4.1.0' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_httpclient-4.5.3' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_httpcore-4.4.6' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_httpmime-4.5.3' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jackson-annotations-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jackson-core-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jackson-databind-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jackson-datatype-jsr310-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_joda-convert-1.2.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_joda-time-2.9.9.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jsoup-1.10.2' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_jta-1.1.txt' with strategy 'discard'
[warn] Merging 'META-INF\LICENSE_xercesImpl-2.11.0' with strategy 'discard'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_commons-codec-1.10.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_commons-io-2.5.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_commons-lang3-3.6.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_commons-logging-1.2.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_guice-4.1.0' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_guice-assistedinject-4.1.0' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_httpclient-4.5.3' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_httpcore-4.4.6' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_httpmime-4.5.3' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_jackson-core-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_jackson-databind-2.8.11' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_joda-convert-1.2.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_joda-time-2.9.9.txt' with strategy 'discard'
[warn] Merging 'META-INF\NOTICE_xercesImpl-2.11.0' with strategy 'discard'
[warn] Merging 'META-INF\README_jsoup-1.10.2' with strategy 'discard'
[warn] Merging 'META-INF\maven\cglib\cglib\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\cglib\cglib\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\ch.qos.logback\logback-classic\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\ch.qos.logback\logback-classic\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\ch.qos.logback\logback-core\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\ch.qos.logback\logback-core\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-annotations\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-annotations\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-core\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-core\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-databind\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.core\jackson-databind\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.errorprone\error_prone_annotations\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.errorprone\error_prone_annotations\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.guava\guava\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.guava\guava\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.j2objc\j2objc-annotations\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.google.j2objc\j2objc-annotations\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.googlecode.usc\jdbcdslog\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.googlecode.usc\jdbcdslog\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.jolbox\bonecp\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.jolbox\bonecp\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.zaxxer\HikariCP\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.zaxxer\HikariCP\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-codec\commons-codec\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-codec\commons-codec\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-io\commons-io\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-io\commons-io\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-logging\commons-logging\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-logging\commons-logging\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\io.jsonwebtoken\jjwt\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\io.jsonwebtoken\jjwt\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.cssparser\cssparser\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.cssparser\cssparser\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.htmlunit\htmlunit\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.htmlunit\htmlunit\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.htmlunit\neko-htmlunit\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\net.sourceforge.htmlunit\neko-htmlunit\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-lang3\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-lang3\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpclient\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpclient\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpcore\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpcore\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpmime\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.httpcomponents\httpmime\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.codehaus.mojo\animal-sniffer-annotations\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.codehaus.mojo\animal-sniffer-annotations\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-api\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-api\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-client\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-client\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-common\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty.websocket\websocket-common\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-client\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-client\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-http\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-http\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-io\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-io\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-util\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.eclipse.jetty\jetty-util\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.jsoup\jsoup\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.jsoup\jsoup\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\jcl-over-slf4j\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\jcl-over-slf4j\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\jul-to-slf4j\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\jul-to-slf4j\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\resources\webjars\product-inventory\1.0-SNAPSHOT\javascripts\main.js' with strategy 'discard'
[warn] Merging 'META-INF\resources\webjars\product-inventory\1.0-SNAPSHOT\stylesheets\bootstrap.min.css' with strategy 'discard'
[warn] Merging 'META-INF\resources\webjars\product-inventory\1.0-SNAPSHOT\stylesheets\main.css' with strategy 'discard'
[warn] Merging 'META-INF\services\com.fasterxml.jackson.core.JsonFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\com.fasterxml.jackson.core.ObjectCodec' with strategy 'discard'
[warn] Merging 'META-INF\services\com.fasterxml.jackson.databind.Module' with strategy 'discard'
[warn] Merging 'META-INF\services\java.sql.Driver' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.servlet.ServletContainerInitializer' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.datatype.DatatypeFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.parsers.DocumentBuilderFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.parsers.SAXParserFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.stream.XMLEventFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.transform.TransformerFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.validation.SchemaFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\javax.xml.xpath.XPathFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\org.apache.commons.logging.LogFactory' with strategy 'discard'
[warn] Merging 'META-INF\services\org.apache.xalan.extensions.bsf.BSFManager' with strategy 'discard'
[warn] Merging 'META-INF\services\org.apache.xml.dtm.DTMManager' with strategy 'discard'
[warn] Merging 'META-INF\services\org.eclipse.jetty.http.HttpFieldPreEncoder' with strategy 'discard'
[warn] Merging 'META-INF\services\org.eclipse.jetty.websocket.api.extensions.Extension' with strategy 'discard'
[warn] Merging 'META-INF\services\org.w3c.dom.DOMImplementationSourceList' with strategy 'discard'
[warn] Merging 'META-INF\services\org.xml.sax.driver' with strategy 'discard'
[warn] Merging 'org\apache\commons\logging\Log.class' with strategy 'first'
[warn] Merging 'org\apache\commons\logging\LogConfigurationException.class' with strategy 'first'
[warn] Merging 'org\apache\commons\logging\LogFactory.class' with strategy 'first'
[warn] Merging 'org\apache\commons\logging\impl\NoOpLog.class' with strategy 'first'
[warn] Merging 'org\apache\commons\logging\impl\SimpleLog$1.class' with strategy 'first'
[warn] Merging 'org\apache\commons\logging\impl\SimpleLog.class' with strategy 'first'
[warn] Merging 'play\reference-overrides.conf' with strategy 'concat'
[warn] Merging 'reference.conf' with strategy 'first'
[warn] Strategy 'concat' was applied to a file
[warn] Strategy 'discard' was applied to 137 files
[warn] Strategy 'first' was applied to 7 files
[info] Assembly up to date: C:\Users\zemcd\Extras\Play_Apps\product-inventory\target\scala-2.12\Product-Inventory-assembly-1.0-SNAPSHOT.jar
[success] Total time: 15 s, completed Mar 21, 2018 11:19:27 AM
此行也包含在内:[info] Including from cache: play-guice_2.12-2.6.12.jar
,此行也是[info] Including from cache: guice-4.1.0.jar
。如果这两个罐子引起冲突,应如何解决?删除jar?或修改合并策略?还有什么其他线索可以解决问题?
答案 0 :(得分:1)
播放documents与sbt-assembly
一起使用的以下合并策略:
assemblyMergeStrategy in assembly := {
case manifest if manifest.contains("MANIFEST.MF") =>
// We don't need manifest files since sbt-assembly will create
// one with the given settings
MergeStrategy.discard
case referenceOverrides if referenceOverrides.contains("reference-overrides.conf") =>
// Keep the content for all reference-overrides.conf files
MergeStrategy.concat
case x =>
// For all the other files, use the default sbt-assembly merge strategy
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
play-scala-sbt-assembly-example是一个工作示例,演示了必要的配置。
答案 1 :(得分:0)
看起来Play拥有自己的dist
函数,该函数在后台使用了sbt本机打包程序插件。我可以按照以下说明操作程序:https://www.playframework.com/documentation/2.7.x/Deploying#Using-the-dist-task