我已經打包使用SBT組裝我的春天啓動的應用程序,並嘗試運行jar當我收到與SBT春季啓動:無法啓動EmbeddedWebApplicationContext由於缺少EmbeddedServletContainerFactory
Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is
org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
該項目工程的IntelliJ就好了。我build.sbt低於
lazy val news = (project in file("wherever")).
enablePlugins(DockerPlugin).
settings(commonSettings: _*).
settings(
name := "name",
mainClass in assembly := Some("mainEntry"),
test in assembly := {},
assemblyJarName := "jarName",
libraryDependencies ++= dependency1,
libraryDependencies ++= dependency2,
libraryDependencies += ScalaTest,
scalaSource in Compile := baseDirectory.value/"src/main/scala",
dockerfile in docker := {
val artifact: File = assembly.value
val artifactTargetPath = "/"
new Dockerfile {
from("openjdk:8-jre-alpine")
add(artifact, artifactTargetPath)
add(new File("./config/"),"/config")
cmd("java", "-jar", " -Denv=$env","jarName")
env("env","stage")
}
},
imageNames in docker := Seq(
ImageName("imageName")
)
)
我做了一些周圍挖掘,它看起來像Spring Boot requires the jar to contain nested jars(而不是尤伯杯罐子等與SBT組件創建)。所以,這給了我兩個選擇。將我的jar打包成sbt的嵌套jar或配置spring以使用正常的classloader並從Uber jar中加載。
我已經研究過嵌套jar sbt插件,我似乎無法找到任何維護的內容(甚至在Maven中心)。 This和this都過時了,而不是maven中心。有沒有人有這樣做的任何建議?
我也研究過配置spring引導來使用uber jar,而壓倒性的響應只是「使用maven插件」,這裏不適用。