從 Spring boot 2.4.13 升級到 2.7.4 后,我開始在容器化 Scala 應用程式上遇到此錯誤(我使用的是 scala 2.12)
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories nor in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:470)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:185)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:125)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:440)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:879)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
at com.eb.data.batch.writer.TermSuccessBatchMainClass$.main(TermSuccessBatch.scala:61)
at com.eb.data.batch.writer.TermSuccessBatchMainClass.main(TermSuccessBatch.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:958)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1046)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1055)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
在進行了一些研究后,我找到了可能的解決方案,例如在plugins.sbt檔案中包含以下插件之一:
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.9.11")
addSbtPlugin("org.springframework.boot" % "spring-boot-maven-plugin" % "2.7.4")
但是,我無法解決這些插件中的最后 2 個,但該檔案包含其他已正確解決的插件,因為我放棄了存盤庫配置問題。確實,第一個可以解決,但沒有解決問題。我還將這一行附加到build.sbt:
enablePlugins(JavaAppPackaging)
[error] (update) sbt.librarymanagement.ResolveException: Error downloading com.typesafe.sbt:sbt-native-packager;sbtVersion=1.0;scalaVersion=2.12:1.9.11
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/com/typesafe/sbt/sbt-native-packager_2.12_1.0/1.9.11/sbt-native-packager-1.9.11.pom
[error] not found: /Users/myuser/.ivy2/localcom.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.9.11/ivys/ivy.xml
[error] unauthorized: https://my-nexus-server/repository/ivy-releases-group/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.9.11/ivys/artifact.xml (Sonatype Nexus Repository Manager)
[error] unauthorized: https://my-nexus-server/repository/public/com/typesafe/sbt/sbt-native-packager_2.12_1.0/1.9.11/sbt-native-packager-1.9.11.pom (Sonatype Nexus Repository Manager)
[error] not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.9.11/ivys/ivy.xml
[error] not found: https://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/1.9.11/ivys/ivy.xml
最后兩個在我的 nexus 存盤庫上引發未經授權的錯誤,但 .sbt 憑據已正確設定,并且它能夠通過 nexus 服務器解決其他插件的任何依賴關系(我猜它是 Not found 代替)。
還嘗試從
lazy val assemblySettings = Seq(
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "spring.factories") => MergeStrategy.filterDistinctLines
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
)
至
lazy val assemblySettings = Seq(
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "spring.factories") => MergeStrategy.filterDistinctLines
case PathList("META-INF", "spring") => MergeStrategy.filterDistinctLines
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
)
因為自動配置似乎已在 spring boot 2.7 上移動,并且錯誤訊息說它也試圖在META-INF/spring它沒有作業下找到它
面對這個問題有什么想法嗎?
uj5u.com熱心網友回復:
由于 spring 自動配置設定已在 spring 2.7 上從META-INF/spring.factoriesto移動META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports,因此在 sbt build 的合并策略上替換此路徑有效:
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "spring.factories") => MergeStrategy.filterDistinctLines
case PathList("META-INF", "spring", "org.springframework.boot.autoconfigure.AutoConfiguration.imports") => MergeStrategy.filterDistinctLines
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/512173.html
標籤:爪哇弹簧靴斯卡拉sbt
