gpt4 book ai didi

java - Gradle 包不存在

转载 作者:行者123 更新时间:2023-12-01 23:19:56 26 4
gpt4 key购买 nike

我正在尝试使用 ./gradlew build 构建 Gradle,但在编译过程中出现以下错误:未找到包。在 Eclipse 中,我可以运行刷新 gradle,但在命令提示符下面临以下问题:

        > Task :compileJava FAILED
/Users/Documents/em-cedm-integ-test/src/main/java/com/BaseTest.java:3: error: package io.restassured does not exist
import static io.restassured.RestAssured.given;
^
/Users/Documents/em-cedm-integ-test/src/main/java/com/BaseTest.java:3: error: static import only from classes and interfaces
import static io.restassured.RestAssured.given;
^
/Users/Documents/em-cedm-integ-test/src/main/java/com/BaseTest.java:21: error: package org.apache.commons.lang3 does not exist
import org.apache.commons.lang3.StringUtils;
^
/Users/Documents/em-cedm-integ-test/src/main/java/com/BaseTest.java:34: error: package io.restassured.response does not exist
import io.restassured.response.ExtractableResponse;
^
/Users/Documents/em-cedm-integ-test/src/main/java/com/BaseTest.java:35: error: package io.restassured.response does not exist
import io.restassured.response.Response;
^
/Users/Documents/em-cedm-integ-test/src/main/java/com/CedmTest.java:3: error: package org.junit.runner does not exist
import org.junit.runner.JUnitCore;
^
^

我正在使用的Build.gradle文件

// Apply the java-library plugin to add support for Java Library

apply plugin: 'java'

allprojects {

repositories {

// You can declare any Maven/Ivy/file repository here.
maven {
url "http://repo.hortonworks.com/content/repositories/releases"
}

maven {
url "${artifactory_contextUrl}"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}

maven {
url "${artifactory_contextUrl}/ip-fci-maven-virtual"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}

}

configurations.all {
transitive = false
}
}



version = '1.0'
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.ibm.cedm.CedmTest'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}


defaultTasks 'downloadFile'
dependencies {

compile group: 'com.google.guava', name: 'guava', version: '12.0.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.7'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.7'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.7'
compile group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.3'
compile group: 'org.apache.hbase', name: 'hbase-client', version: '1.1.2.2.6.4.0-91'
compile group: 'org.apache.hbase', name: 'hbase-common', version: '1.1.2.2.6.4.0-91'
compile group: 'org.apache.hbase', name: 'hbase-client', version: '1.1.2.2.6.4.0-91'
compile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.7.3.2.6.4.0-91'
compile group: 'com.tdunning', name: 'json', version: '1.8'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.10'
compile group: 'org.apache.oozie', name: 'oozie-client', version: '4.2.0'
compileOnly group: 'io.swagger', name: 'swagger-annotations', version: '1.5.12'
compileOnly group: 'javax', name: 'javaee-api', version: '7.0'
compile group: 'ip-fci-generic-local.fcco-core', name: 'fci-core-utils', version: 'master'
compile(group: 'ip-fci-generic-local.media', name: 'db2jcc4', version: '11.1.3')



testImplementation 'junit:junit:4.12'

testCompile group: 'commons-codec', name: 'commons-codec', version: '1.9'
testCompile group: 'com.tdunning', name: 'json', version: '1.8'
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
testCompile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.6'
testCompile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.10'
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'
testCompile group: 'commons-logging', name: 'commons-logging', version: '1.2'
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.0.2'
testCompile group: 'io.rest-assured', name: 'rest-assured-common', version: '3.0.2'
testCompile group: 'io.rest-assured', name: 'json-path', version: '3.0.2'
testCompile group: 'io.rest-assured', name: 'xml-path', version: '3.0.2'
testCompile group: 'net.javacrumbs.json-unit', name: 'json-unit', version: '1.5.2'
testCompile group: 'net.javacrumbs.json-unit', name: 'json-unit-core', version: '1.5.2'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.codehaus.groovy', name: 'groovy', version: '2.4.4'
testCompile group: 'org.codehaus.groovy', name: 'groovy-json', version: '2.4.4'
testCompile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.25'

}

/*
test {
filter {
//include specific method in any of the tests
includeTestsMatching "*createBasicIndividualParty"

}
}
*/

有人可以告诉我为什么会这样吗?我应该做出哪些改变才能使其发挥作用?

最佳答案

如何映射依赖关系

  1. 使用 testCompile 映射的依赖项将使用 src/test/java 类进行编译
  2. 使用 compile 映射的依赖项将使用 src/main/java 类进行编译

gradle 配置问题

很少有依赖项被映射为 testCompile,但可以在生产代码 src/main/java 中引用它。

testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'

应该是

compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'

关于java - Gradle 包不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58331257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com