我无法从我的 Artifactory 存储库中提取任何依赖项,如果它们是某种格式的话。然而,无论格式如何,maven 都能毫无问题地提取所有这些依赖项。
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find eu.****:cloudnet-bridge:1.0.0.
Searched in the following locations:
- https://repo.****.dev:443/artifactory/****-repo/eu/****/cloudnet-bridge/1.0.0/cloudnet-bridge-1.0.0.pom
- https://repo.****.dev:443/artifactory/****-repo/eu.****/cloudnet-bridge/ivy-1.0.0.xml
Required by:
project :
这是我在使用 gradle (6.5) 的 IntelliJ(2020.1.2 社区版)中遇到的错误。
This is the folder structure for a non-working dependency (jar直接放在文件夹里)
This is the folder structure for a working dependency (jar 与有效的 POM 一起位于版本文件夹中;人工自动生成的在这里不起作用!依赖项的根文件夹中还有一个 xml 文件,其中包含有关版本等的一些信息。)
现在我的问题是我是否可以解决这个问题。
最佳答案
问题似乎是缺少 .pom
。
默认情况下,Gradle 6 无法找到依赖项,除非它们具有元数据。这是 Gradle 5 行为的一个变化。您可以通过向存储库声明添加 metadataSources
block 来自定义它,如下所示:
repositories {
maven {
url = uri("https://repo.****.dev:443/artifactory/****-repo")
metadataSources {
mavenPom()
artifact()
}
}
}
这意味着,“首先查找 .pom
,但如果没有 .pom
,则查找 .jar
。”
如果 repo 包含任何内容,您可能还想添加 gradleMetadata()
。
关于java - 如果未以某种格式提供,Gradle 无法解析我的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62647590/