简体   繁体   English

如何导入 gradle 依赖项

[英]How to import a gradle dependency

I'm learning Spring Boot.我正在学习 Spring 引导。 I already declare hateoas dependency and build it successfully.我已经声明了 hatoas 依赖并成功构建它。 (I use Gradle). (我使用 Gradle)。 But I still can't import EntityModel.但我仍然无法导入EntityModel。 What is wrong?怎么了? 在此处输入图像描述

// build.gradle
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-hateoas'
    runtimeOnly 'com.h2database:h2'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Make sure you build the project so the dependencies get downloaded, using the build tool in your IDE or from the Terminal first.确保构建项目以便下载依赖项,使用 IDE 中的构建工具或首先从终端。

Try importing: 尝试导入:

 import org.springframework.hateoas.EntityModel

and in gradle try the artifact org.springframework.hateoas:spring-hateoas并在 gradle 中尝试工件org.springframework.hateoas:spring-hateoas

What a surprise.真是个惊喜。 Today, I just open my IDE then the problem is solved.今天刚打开我的IDE,问题就解决了。

// build.gradle
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-hateoas'
    runtimeOnly 'com.h2database:h2'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

I tried these command:我尝试了这些命令:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM