Try to search your question here, if you can't find : Ask Any Question Now ?

How to fix "Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader" in Spring Tool Suite

HomeCategory: stackoverflowHow to fix "Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader" in Spring Tool Suite
rupesh asked 7 days ago

Spring Tool Suite editor is not giving any errors in my code but when I try to run as Spring Boot App, it gives me an exception of class def not found. All I am trying to do here is run the Spring Boot App which shows the spring boot logo in the console

I have checked all the dependencies in my xml file and they seem ok but not entirely sure.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:428)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:268)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at com.example.ToDoAppApplication.main(ToDoAppApplication.java:10)


Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.support.SpringFactoriesLoader
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

Should just see that spring boot app is running successfully in the console without any errors.

Here is my xml file:

<?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 http://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>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>ToDoApp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ToDoApp</name>
    <description>ToDoApp for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.3.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.1.4.RELEASE</version><!--$NO-MVN-MAN-VER$-->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.15</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>5.1.5.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>5.1.5.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.security/org.springframework.security.config -->
<!--    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.config</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency> -->


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Here is my xml file

<?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 http://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>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>ToDoApp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ToDoApp</name>
    <description>ToDoApp for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.3.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.1.4.RELEASE</version><!--$NO-MVN-MAN-VER$-->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.15</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>5.1.5.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>5.1.5.RELEASE</version><!--$NO-MVN-MAN-VER$-->
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.security/org.springframework.security.config -->
<!--    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.config</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency> -->


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
1 Answers
Best Answer
Mikhail answered 7 days ago
Your Answer

18 + 7 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com