@SpringBootApplication无法解析为STS中的类型

问题描述 投票:12回答:7

我对STS很新。我在stackoverflow中搜索了这个错误。我找不到正确的匹配答案。

我能够在STS中看到Maven Dependencies部分中的类,但是无法在我的java类中添加注释。

qazxsw poi我们将非常感谢您的帮助。谢谢

enter image description here

java spring spring-boot spring-tool-suite
7个回答
49
投票

转到您的maven存储库目录对于以下路径的窗口enter image description here然后删除C:\Users\YourUser\.m2\repository\org\springframework\boot文件夹。

现在去eclipse spring-boot-autoconfigure

这解决了我的问题。


2
投票

从命令行运行bellow命令

Right click on project -> Maven -> Update Project

选择项目并做一个maven-> update这解决了我的问题


0
投票

只需将您的弹簧启动版本从1.5.8更改为1.5.6。相信我,我已经尝试了所有其他解决方案,但只有这个解决方案适合我。


0
投票

清除.m2 /文件位置下的org / springframework / boot文件夹,并在项目下运行mvn clean install命令


0
投票

上述解决方案都不适用于我,因为我的代码就是这样

mvn clean dependency:tree
mvn clean compile

我错过了导致此错误的<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.2.RELEASE</version> </parent> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <properties> <java.version>1.8</java.version> </properties> 标签。


-1
投票

在包声明下面添加import语句。

import org.springframework.boot.autoconfigure.SpringBootApplication;

您只需要将该注释添加到入口点,而不是每个类。它与拥有启动Spring的主要方法的同一个类...

<dependencies>

-1
投票

我有同样的问题。您可以使用 public static void main(String[] args) { SpringApplication.run(CourseAPIApp.class, args); } 目标构建项目来解决它。

© www.soinside.com 2019 - 2024. All rights reserved.