[英]java.lang.NoSuchMethodError while running spring boot application
运行 Spring Boot 应用程序时出现以下错误。 有人可以帮忙吗?
应用类
package com.dell.cns.services.esb.heartbeat.satcps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("com.dell.cns.services.esb")
public class CnsServicesHeartBeatSatcpsApplication {
public static void main(String[] args) {
SpringApplication.run(CnsServicesHeartBeatSatcpsApplication.class, args);
}
}
错误信息
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.boot.SpringApplication.run(Ljava/lang/Class;[Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;
at com.dell.cns.services.esb.heartbeat.satcps.CnsServicesHeartBeatSatcpsApplication.main(CnsServicesHeartBeatSatcpsApplication.java:12)
如果您使用的是Intellij IDEA ,请执行以下操作:
菜单 -> 文件 -> 无效缓存/重启
我遇到了同样的问题并通过右键单击项目-> Maven-> 更新项目来修复它。 然后应用程序在 Tomcat 服务器上启动并运行。
更新到 Java 11 后,SpringBoot 应用程序会抛出许多错误。 我将 Spring boot 版本更新为 2.4.0 并在 main 方法中进行了如下更改:
ConfigurableApplicationContext context = SpringApplication.run(Application.class,args);
构建并尝试再次运行应用程序后,会抛出如下错误
“NoSuchMethodError:'org.springframework.context.ConfigurableApplicationContext org.springframework.boot.SpringApplication.run”
并通过右键单击项目 -> Maven -> 更新 maven 项目来修复它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.