MKP010
MKP010

Reputation: 71

java.lang.NoSuchMethodError while running spring boot application

Getting below error while running a spring boot application. Can anybody help?

Application Class

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);
    }
}

Error Message

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)

Upvotes: 1

Views: 21493

Answers (4)

Guy_g23
Guy_g23

Reputation: 385

I had a similar error related to Spring Boot and Maven 3.8.* build tool. The solution in my case is to change Maven home path (In ItennliJ IDEA Build Tools) to Bundled (Maven 3)

Upvotes: 0

Christina
Christina

Reputation: 11

After updating to Java 11 , SpringBoot applications throw many errors. I updated Spring boot version to 2.4.0 and made the changes in main method as below:

ConfigurableApplicationContext context = SpringApplication.run(Application.class,args);

After building and trying to run the application again throws the error like below

"NoSuchMethodError: 'org.springframework.context.ConfigurableApplicationContext org.springframework.boot.SpringApplication.run"

and fixed it by Right click on project -> Maven -> Update maven project

Upvotes: 1

AlgoDSExpert
AlgoDSExpert

Reputation: 9

I faced the same issue and fixed it by right-clicking on project->Maven->Update project. The App was then up and running on Tomcat server.

Upvotes: 1

Ghasem Sadeghi
Ghasem Sadeghi

Reputation: 1854

If you are using Intellij IDEA, do the following:
Menu -> File -> invalidate cache/restart

Upvotes: 3

Related Questions