无法解析导入 org.springframework.web。蚀

The import org.springframework.web cannot be resolved. Eclipse

无法解析导入 org.springframework.web。

Eclipse 无法导入 Spring 个库。

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import task1.exception.NotFoundException;

我的 build.gradle 文件:

plugins {
id 'org.springframework.boot' version '1.5.3.RELEASE'
id 'java'
}



apply plugin: 'io.spring.dependency-management'
apply plugin: 'eclipse'

group = 'task1'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
mavenCentral()
}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
 compile("org.springframework.boot:spring-boot-starter-web")
}

但是当我在终端中构建这个项目时,它已经构建并且 运行。

尝试右键单击 build.gradle 文件并执行:

file -> Gradle -> Refresh Dependencies