IntelliJ Idea没有看到Gradle添加的依赖项

时间:2018-03-28 19:16:12

标签: java gradle intellij-idea

我有 build.gradle 文件:

onClick

构建任务成功执行:

group 'com.test'
version '1.0'

apply plugin: 'java'

sourceCompatibility = 1.5

jar {
    baseName = 'test'
    version =  '0.0.1'
}

repositories {
    jcenter()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

ext{
    //versions of dependencies
    springVersion = '5.0.4.RELEASE'
    springBootVersion = '2.0.0.RELEASE'
    springJPAVersion = '2.0.5.RELEASE'
    javaxVersion = '1.0.2'
}

dependencies {
    implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
    implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
    implementation "org.springframework.data:spring-data-jpa:${springJPAVersion}"
    implementation "javax.persistence:persistence-api:${javaxVersion}"
    testImplementation group: 'junit', name: 'junit', version: '4.11'
}

C:\ Users \ admin.gradle \ caches \ modules-2 \ files-2.1 \ javax.persistence \ persistence-api \ 1.0.2 \ 8 ... a Gradle下载存档 persistence-api-1.0.2.jar ,其中包含 javax \ persistence \ Entity.class

但是当我试图添加行时:

21:56:37: Executing external task 'build'...
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava NO-SOURCE
:processTestResources NO-SOURCE
:testClasses UP-TO-DATE
:test NO-SOURCE
:check UP-TO-DATE
:build UP-TO-DATE

BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 up-to-date
21:56:37: External task execution finished 'build'.

在任何一个类中,IntelliJ Idea都用红色强调持久性。为什么以及如何解决它?

1 个答案:

答案 0 :(得分:1)

最后,我推动了#34;刷新所有Gradle项目"在 Gradle项目窗口中:

enter image description here

并且所有依赖项突然出现在项目结构中的模块依赖项中。之后我的问题得到解决。