0

I'm learning Spring Boot using STS and following a tutorial on Udemy. I'm getting the following error when trying to run the app as a java application. I have looked at other similar posts and nothing seems to be new. Most of the questions are from 3-5 years ago. I have attempted putting some dependencies in my pom but it gave me more errors than I began with so i removed them.

The error is: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

here is my pom.xml:

<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>
<groupId>com.in28minutes.springboot</groupId>
<artifactId>first-springboot-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
</parent>

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

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

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

Here is what i was trying to run:

package com.in28minutes.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(Application.class, 
    args);

    }

}

Does anyone have a suggestion to what I can do to fix this? Do I bind? The original example code can be found here at the instructor's repo: https://github.com/in28minutes/SpringBootForBeginners/blob/master/Step01.md

Yasin Shuman
  • 127
  • 2
  • 14
  • 1
    Where's the error? – dgzz Jul 07 '17 at 03:41
  • It needs to run as an spring boot application. Not a java application. The spring container does a lot of stuff specific to it. – bichito Jul 07 '17 at 04:58
  • I thought maybe the instructor misspoke in the video so I tried that. I get the same error if I try to run it as a spring boot application. – Yasin Shuman Jul 07 '17 at 05:04
  • check ~/.m2 folder to make sure it is there – bichito Jul 07 '17 at 05:08
  • @efekctive I appreciate your patience. I'm still new to all of this (maven,spring etc...). I went to my .m2 folder and drilled down on the slf4j folder and i see the following: jcl-over-slf4j , slf4j-api , slf4j-parent , jul-to-slf4j , slf4j-jdk14 , slf4j-simple , log4j-over-slf4j , slf4j-log4j12 – Yasin Shuman Jul 07 '17 at 05:25
  • https://stackoverflow.com/questions/11916706/slf4j-failed-to-load-class-org-slf4j-impl-staticloggerbinder-error – bichito Jul 07 '17 at 12:26

1 Answers1

0

I'm not use STS but following from this docs you should run your app as Spring Boot App since you're using Spring Boot. But your error it's seems because dependency error, if you familiar with command line I suggest you to perform mvn clean install before run your Spring project to make sure all the dependency is downloaded.

Another tips, if you're good with command line try to execute mvn spring-boot:run on your project directory and it will execute your Spring project.

Sukma Wardana
  • 540
  • 8
  • 21