sbt spring-boot fat jar在META-INF / spring.factories中找不到自动配置类

时间:2018-08-08 22:11:08

标签: scala spring-boot sbt sbt-assembly

对于作为春季启动Web应用程序的sbt项目,我正在使用sbt assembly创建一个胖jar。运行java -jar foo.jar

这样的jar文件时出现以下错误

java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.

使用mvn时有针对此问题的解决方案,但我无法将其应用于sbt项目。以下是build.sbt:

name := "foo"
version := "0.1"
scalaVersion := "2.12.6"
libraryDependencies +=
  "org.springframework.boot" % "spring-boot-starter-web" % "2.0.4.RELEASE"
mainClass in assembly := Some("com.foo.Application")
assemblyMergeStrategy in assembly := {
  case manifest if manifest.contains("MANIFEST.MF") =>
    MergeStrategy.discard
  case _ =>
    MergeStrategy.first
}

0 个答案:

没有答案