无法将RxJava dep添加到gradle

时间:2019-01-08 06:55:06

标签: java gradle rx-java

我正在尝试使用Rxjava,并且像这样将它添加到了我的gradle中:

但是,我无法在src目录中使用它-自动完成功能不会显示有关Observable的任何建议。

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    flatDir {
        dirs 'lib'
    }
}

sourceSets {
    test {
        java {
            srcDir 'src/test/java'
        }
    }

}

dependencies {
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile 'junit:junit:4.12'
    testCompile 'org.assertj:assertj-core:1.7.1'
    testCompile 'io.reactivex:rxjava:1.0.7'
    testCompile 'io.reactivex:rxjava-math:1.0.0'
    testCompile 'io.reactivex:rxjava-string:0.22.0'
    compile 'io.reactivex.rxjava2:rxjava:2.2.0'

}

test {
    testLogging {
        events "passed", "skipped", "failed", "standardOut", "standardError"
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}

我希望能够在源目录中使用依赖项。

1 个答案:

答案 0 :(得分:0)

将依赖项添加到 build.gradle 文件后,您需要 build gradle项目。这将下载所有依赖项,然后自动完成将显示建议。

Eclipse 中,您可以执行以下操作:

Right Click on Project module-> Gradle->Refresh Gradle project

否则,在命令提示符下,您可以使用以下命令:

gradlew build