简体   繁体   English

Package ratpack.test 不存在

[英]Package ratpack.test does not exist

I have a Gradle, Intellij-idea project and I'm using ratpack.我有一个 Gradle、Intellij-idea 项目,我正在使用 ratpack。 I'm trying to use the ratpack.test library to test my API however it cannot seem to find the ratpack.test package.我正在尝试使用 ratpack.test 库来测试我的 API 但是它似乎找不到 ratpack.test package。

When compiling it says package ratpack.test does not exist.编译时说 package ratpack.test 不存在。

Gradle: io.ratpack:ratpack-test 1.7.5 is in my external libraries and module. Gradle: io.ratpack:ratpack-test 1.7.5 在我的外部库和模块中。

Upon the error if I hover over the ratpack.test import it says add library 'Gradle: io.ratpack:ratpack-test 1.7.5' to classpath which I click.如果我通过 ratpack.test 导入 hover 出现错误,它会说将库 'Gradle: io.ratpack:ratpack-test 1.7.5' 添加到我单击的类路径。 Then when I try to build again it breaks with the same error.然后,当我尝试再次构建时,它会因相同的错误而中断。

build.gradle file build.gradle文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.ratpack:ratpack-gradle:1.7.5"
    }
}

plugins {
    id 'java'
}

group 'MIR.Interviwer.API'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
}

apply plugin: "io.ratpack.ratpack-java"
apply plugin: "idea"

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'junit:junit:4.12'
    runtime "org.slf4j:slf4j-simple:1.7.25"
    runtime "com.h2database:h2:1.4.199"
}

ratpack.baseDir = file('ratpack')

Any ideas?有任何想法吗? Thanks.谢谢。

The only thing I can think of is if you are attempting to import the Ratpack test classes in your main module, where they are not available (after all, they are test classes and are only available in the test module).我唯一能想到的是,如果您尝试在main模块中导入 Ratpack 测试类,它们不可用(毕竟,它们是测试类,仅在test模块中可用)。

Just as a heads up, you are also using deprecated configurations.请注意,您还使用了已弃用的配置。 So unless you are in a legacy project with an old version, use these instead:因此,除非您在使用旧版本的遗留项目中,否则请改用这些:

  • testCompile -> testImplementation testCompile -> testImplementation
  • compile -> implementation compile -> implementation
  • runtime -> runtimeOnly runtime -> runtimeOnly

You can also get rid of the entire buildscript block and the apply plugin: "io.ratpack.ratpack-java" line, and just type:你也可以去掉整个buildscript块和apply plugin: "io.ratpack.ratpack-java"行,然后输入:

plugins {
  id "io.ratpack.ratpack-java" version "1.7.5"
}

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

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