Java.Lang.Classnotfoundexception: Org.Springframework.Boot.Springapplication Maven

java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication Maven

Your jar does not contain the dependencies such as spring-boot which it is looking for during runtime. You can build a consolidated jar with all the dependencies as outlined in this question.

Spring: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication not found

  1. you should remove the maven-jar-plugin

  2. modify spring-boot-maven-plugin to:

     <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.0.3.RELEASE</version>
    <configuration>
    <mainClass>com.game.Main</mainClass>
    </configuration>
    </plugin>
  3. you can execute mvn package spring-boot:repackage to generate the executable jar

Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

I was able to solve this by downgrading Spring Boot:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>

Guess it's just not compatible with 2.4.0 yet.

Specifically I also had to ensure that I used 2.3.3.RELEASE and not anything more recent due to other issues I ran across.

How to fix the error 'java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver' in a spring-boot application?

This is because of using the spring-boot-starter-parent version as 2.x but trying to use the older versision 1.5.x for a related dependency, say spring-boot-autoconfigure.

The code below will cause this error because the dependency version is not matching from that of the parent.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.5.13.RELEASE</version>
</dependency>
</dependencies>

java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication

What no one ever said in the answers to other questions is that you need to use maven to create the jar and not using Eclipse's export to jar option. What you need to do is:

1) download maven from https://maven.apache.org/download.cgi

2) The maven dir contains a 'bin' folder. Add this folder to your "path" enviornment variable (on Windows 8 right click "This PC" -> properties -> Advanced System Settings -> Environment Variables -> in System Variables find "Path" -> double click it and add it by adding the bin folder path to that variable the same way other paths are located there.

3) open CMD

4) navigate to your project's folder

5) type mvn package

The jar file is created inside the "target" folder.

Good luck



Related Topics



Leave a reply



Submit