79727545

Date: 2025-08-06 16:02:04
Score: 2
Natty:
Report link

start your spring boot project from here:

https://start.spring.io/

enter image description here

get project.zip

unzip the project.zip

you can find: pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.4</version>
        <relativePath/>
    </parent>
    <groupId>com.emea</groupId>
    <artifactId>project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>project</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>21</java.version>
    </properties>
    <dependencies>
        <dependency>            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

(1) Use the spring-boot-maven-plugin to build the Spring Boot application JAR. Do not use the maven-jar-plugin.

(2) In the section of your pom.xml, do not manually specify the versions of dependencies that are already managed by Spring Boot (e.g., 3.5.3, 1.18.38, 6.2.9).

(3) You can use the mvn dependency:tree command to identify the libraries and versions that are already included by Spring Boot.

package and run:

package

mvn clean package

run

java -jar target/project-0.0.1-SNAPSHOT.jar

then everything is ok!

2025-08-06T23:52:06.643+08:00  INFO 17710 --- [project] [           main] com.emea.project.ProjectApplication      : Started ProjectApplication in 1.387 seconds (process running for 1.986)

To reproduce your issue, simply modify the pom.xml as follows:

add

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
        <archive>
            <manifest>
                <mainClass>${exec.mainClass}</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>

remove

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </exclude>
        </excludes>
    </configuration>
</plugin>

add

<exec.mainClass>com.emea.project.ProjectApplication</exec.mainClass>

into <properties>

modify ProjectApplication.java like yours.

package and run:

package

mvn clean package

run

java -jar target/project-0.0.1-SNAPSHOT.jar

then get the same error:

$ java -jar target/project-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.emea.project.ProjectApplication.<clinit>(ProjectApplication.java:11)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    ... 1 more

how to fix ?

Reasons:
  • Whitelisted phrase (-1.5): You can use
  • RegEx Blacklisted phrase (1.5): how to fix ?
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): get the same error
  • Ends in question mark (2):
  • High reputation (-1):
Posted by: life888888