【问题标题】:@SpringBootApplication not recognized when using spring-boot-starter-parent version 1.5.9.RELEASE使用 spring-boot-starter-parent 版本 1.5.9.RELEASE 时无法识别 @SpringBootApplication
【发布时间】:2018-05-14 23:32:38
【问题描述】:

从 SPRING STS 我创建了一个全新的 spring boot 项目启动器,我添加了“WEB”功能,然后完成了项目的创建

由于某种原因导入

import org.springframework.boot.autoconfigure.SpringBootApplication;

无法识别(我得到-“无法解析导入 org.springframework.boot.autoconfigure.SpringBootApplication”)

因此@SpringBootApplication注解也无法识别

package com.test;

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

    @SpringBootApplication
    public class Newtest1sdfsdfApplication {

        public static void main(String[] args) {
            SpringApplication.run(Newtest1sdfsdfApplication.class, args);
        }
    }

注意:我使用的是自动创建的项目

如果我更改 spring-boot-starter-parent 的项目版本(在 pom.xml 中) 从 1.5.9 到 1.5.8 - 一切都好起来了。设置回 1.5.9 显示错误

意思从:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

有什么想法吗?

【问题讨论】:

  • 试试this SO post的建议。我找不到上述版本的任何问题...

标签: spring-boot


【解决方案1】:

我结束了:

  1. .m2 文件夹中删除两个 子文件夹 子文件夹是:orgcom

  2. 然后 -> 从 eclipse/STS :右键单击项目名称 -> MAVEN -> UPDATE PROJECT

【讨论】:

    最近更新 更多