【发布时间】:2020-11-25 01:30:00
【问题描述】:
我有一个带有 IntelliJ-Idea IDE 的应用程序,它的 Springboot 配置出错并给出以下建议:
The following method did not exist:
org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(Lorg/springframework/core/metrics/ApplicationStartup;)V
The method's class, org.springframework.context.ConfigurableApplicationContext, is available from the following locations:
jar:file:/C:/Users/tlmitch/.m2/repository/org/springframework/spring-context/5.2.8.RELEASE/spring-context-5.2.8.RELEASE.jar!/org/springframework/context/ConfigurableApplicationContext.class
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.context.ConfigurableApplicationContext
我对 IntelliJ-Idea 和 Springboot 比较陌生。如果这是说 Eclipse - 我可能只是去 Java 构建路径并添加包含该类的 jar 文件。
我对 IntelliJ 不太熟悉。到目前为止,如果缺少某些东西,我一直在运行“npm install”,这通常会解决它。
有什么建议吗?
非常感谢
【问题讨论】:
-
您的错误提到 .m2 - 这向我暗示了 Maven。如果您的 pom.xml 调用 spring-boot-starter-parent 它会将 Spring JAR 带入项目。如果您不使用 Maven,则应该这样做。如果不能,则应将 JAR 添加到 /lib 文件中,并将所有这些 JAR 添加到项目配置中的 CLASSPATH 中。坚持使用 IntelliJ - 它比 Eclipse 更好。
-
谢谢 - 我很感激。是的,我正在使用 Maven。 pom.xml 文件中没有任何类型的父标记。关于更正类路径 - 我可以看到 spring-context-5.2.8.RELEASE 库在依赖项中列出的位置。我只是不确定如何解决这个问题。
-
找到父级并使用它。您应该使用 Soring Boot,而不是原始的 Soring。
标签: java spring-boot intellij-idea