弹簧工具套件作为 Java 应用程序运行时出错



我正在使用STS学习Spring Boot,并遵循Udemy上的教程。尝试将应用程序作为 java 应用程序运行时,我收到以下错误。我看过其他类似的帖子,似乎没有什么新东西。大多数问题来自 3-5 年前。我尝试在我的pom中放置一些依赖项,但它给了我比开始时更多的错误,所以我删除了它们。

错误是: 无法加载类"org.slf4j.impl.StaticLoggerBinder">

这是我的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>

这是我尝试运行的内容:

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

有没有人对我能做些什么来解决这个问题有建议?我绑定吗?原始示例代码可在教师的存储库中找到:https://github.com/in28minutes/SpringBootForBeginners/blob/master/Step01.md

我不使用 STS,但根据本文档,您应该将应用程序作为Spring Boot 应用程序运行,因为您使用的是 Spring Boot。 但是你的错误似乎是因为依赖错误,如果你熟悉命令行,我建议你在运行Spring项目之前执行mvn clean install以确保下载所有依赖关系。

另一个提示,如果你擅长命令行,尝试在你的项目目录上执行mvn spring-boot:run,它将执行你的Spring项目。

相关内容

最新更新