gpt4 book ai didi

gradle 本地 jar 依赖项不起作用

转载 作者:行者123 更新时间:2023-12-01 04:41:14 25 4
gpt4 key购买 nike

我对 gradle 很陌生。
这是我的项目配置

Project
.
├── build.gradle
├── sub-project-1
│   ├── build.gradle
├── tests
│   ├── rest
│   └── unit
│   ├── build.gradle // Lets call this unit_build.gradle

我的单元测试依赖于 derby.jar,并且 unit_build.gradle 具有以下内容:
dependencies{
..
testCompile fileTree(dir: "${System.getProperty('java.home')}/../db/lib", include: "derby.jar")
testCompile fileTree(dir: "${System.getProperty('java.home')}/../db/lib", include: "derbyclient.jar")
}

注意:我们有自己的存储库,其中不包括 derby。所以我们通过从本地添加它来使用它。

当我运行 gradle 构建,然后是我的测试任务时,这很好用。

但是我们也将 jar 发布到测试服务器并在那里运行它,它在 derby 上失败并出现 class not found 异常。

原因是什么?应该怎么做才能解决这个问题?

Gradle 版本 - 1.12

最佳答案

发生这种情况是因为您选择了错误的目标依赖项配置。我的意思是 testCompile , 而不是你应该使用: testRuntimetestRuntimeClasspath

关于gradle 本地 jar 依赖项不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50055696/

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