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

时间:2019-02-14 12:37:53

标签: java eclipse spring-boot eclipse-plugin build.gradle

导入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")
}

enter image description here

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

1 个答案:

答案 0 :(得分:1)

尝试右键单击build.gradle文件,然后执行以下操作:

file -> Gradle -> Refresh Dependencies