【发布时间】:2020-09-11 11:22:23
【问题描述】:
我正在关注 Spring Boot 文档https://spring.io/guides/gs/spring-boot/ 但是在我做了与添加单元测试步骤相同的操作之后,即使我有相同的 gradle 文件,项目也不会因为导入失败而构建。
gs-spring-boot\complete\src\main\java\com\example\springboot\HelloControllerTest.java:3: error: package org.hamcrest does not exist
import static org.hamcrest.Matchers.equalTo;
^
error: package org.assertj.core.api does not exist
import static org.assertj.core.api.Assertions.*;
我的gradle文件内容
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
整个项目设置都在https://github.com/spring-guides/gs-spring-boot/archive/master.zip中给出
这里出了什么问题?我有 java SDK 设置,我可以在这一步之前运行 http 服务器。我在使用 IntelliJ 及其内置 gradle 的 Windows 10 上。
【问题讨论】:
标签: java spring-boot gradle intellij-idea