Azure DevOps 中的 Maven 找不到 jar
Maven in Azure DevOps can't find jar
我正在使用 Azure DevOps YAML 构建管道来编译一些 java 代码。 java 代码使用 azure-storage-blob
TL;DR
我可以安装一堆 maven jar 但 azure-storage-blob returns“找不到工件”。我注意到它的路径是 https://repo1.maven.org
,而不是 https://repo.maven.org
更多详情
除此之外,我的 pom.xml:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.0</version>
</dependency>
部分 Maven 输出如下所示:
Downloaded from central: https://repo.maven.apache.org/maven2/com/microsoft/azure/azure-keyvault-core/1.0.0/azure-keyvault-core-1.0.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-nop/1.7.21/slf4j-nop-1.7.21.jar (4.0 kB at 660 B/s)
Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/20.0/guava-20.0.jar (2.4 MB at 399 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:53 min
[INFO] Finished at: 2021-11-26T12:22:10Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XYZ: Could not resolve dependencies for project com.function:Decryption_POC_JAVA:jar:1.0-SNAPSHOT: Could not find artifact com.azure:azure-storage-blob:jar:12.4.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The process '/usr/bin/mvn' failed with exit code 1
Could not retrieve code analysis results - Maven run failed.
所以它可以成功地从
https://repo.maven.apache.org/maven2/com/microsoft/azure/
但它不能只下载 blob jar
我发现这个文件不存在:
https://repo.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar
(我假设这是它正在寻找的地方,但我无法显示它)
但是这个文件是这样的:
https://repo1.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar
注意这是 repo1 而不是 repo。我只发现这个是因为 this Maven 页面指定了它。
所以我试图通过将其添加到 pom.xml
来强制查看 repo1
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central1</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
错误变为
Failed to collect
dependencies at com.azure:azure-storage-blob:jar:12.4.0: Failed to
read artifact descriptor for com.azure:azure-storage-blob:jar:12.4.0:
Could not transfer artifact com.azure:azure-storage-blob:pom:12.4.0
from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror
for repositories: [central1 (http://repo1.maven.org/maven2, default
我的问题是:
- 我可以让 maven 显示 URL 它是从哪里下载的吗?
- 为什么这个文件在 repo1 而不是 repo(其他文件在 repo 而不是 repo1)
- 如果 maven 这么棒,为什么会发生这种愚蠢的事情,我该如何解决它
请注意,我使用的是 Azure DevOps,我没有很多 Maven 经验,所以我不确定我是否可以清除缓存或清除本地 Maven 存储库或类似的东西。这也是我正在尝试使用的现有设置。
以下是重要的 YAML 部分:
trigger:
paths:
include:
- "src/*"
- "pom.xml"
stages:
- stage: Build
jobs:
- job: mavenBuild
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
我在 Azure Pipeline Could not find artifact com.azure:azure-storage-blob:jar:12.4.0
中也发现了这个问题。
我从这个 maven link 中发现了一些有趣的东西,那就是 Jar (474KB)
link 已经坏了。所以我把com.azure:azure-storage-blob:jar
版本改成了最新版本12.14.2
.
这是工作。 Azure Pipelines 可以从 Maven Central Repo 下载这个工件。
我正在使用 Azure DevOps YAML 构建管道来编译一些 java 代码。 java 代码使用 azure-storage-blob
TL;DR
我可以安装一堆 maven jar 但 azure-storage-blob returns“找不到工件”。我注意到它的路径是 https://repo1.maven.org
,而不是 https://repo.maven.org
更多详情
除此之外,我的 pom.xml:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.0</version>
</dependency>
部分 Maven 输出如下所示:
Downloaded from central: https://repo.maven.apache.org/maven2/com/microsoft/azure/azure-keyvault-core/1.0.0/azure-keyvault-core-1.0.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-nop/1.7.21/slf4j-nop-1.7.21.jar (4.0 kB at 660 B/s)
Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/20.0/guava-20.0.jar (2.4 MB at 399 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:53 min
[INFO] Finished at: 2021-11-26T12:22:10Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XYZ: Could not resolve dependencies for project com.function:Decryption_POC_JAVA:jar:1.0-SNAPSHOT: Could not find artifact com.azure:azure-storage-blob:jar:12.4.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The process '/usr/bin/mvn' failed with exit code 1
Could not retrieve code analysis results - Maven run failed.
所以它可以成功地从 https://repo.maven.apache.org/maven2/com/microsoft/azure/
但它不能只下载 blob jar
我发现这个文件不存在:
https://repo.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar
(我假设这是它正在寻找的地方,但我无法显示它)
但是这个文件是这样的:
https://repo1.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar
注意这是 repo1 而不是 repo。我只发现这个是因为 this Maven 页面指定了它。
所以我试图通过将其添加到 pom.xml
来强制查看 repo1 <repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central1</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
错误变为
Failed to collect dependencies at com.azure:azure-storage-blob:jar:12.4.0: Failed to read artifact descriptor for com.azure:azure-storage-blob:jar:12.4.0: Could not transfer artifact com.azure:azure-storage-blob:pom:12.4.0 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [central1 (http://repo1.maven.org/maven2, default
我的问题是:
- 我可以让 maven 显示 URL 它是从哪里下载的吗?
- 为什么这个文件在 repo1 而不是 repo(其他文件在 repo 而不是 repo1)
- 如果 maven 这么棒,为什么会发生这种愚蠢的事情,我该如何解决它
请注意,我使用的是 Azure DevOps,我没有很多 Maven 经验,所以我不确定我是否可以清除缓存或清除本地 Maven 存储库或类似的东西。这也是我正在尝试使用的现有设置。
以下是重要的 YAML 部分:
trigger:
paths:
include:
- "src/*"
- "pom.xml"
stages:
- stage: Build
jobs:
- job: mavenBuild
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
我在 Azure Pipeline Could not find artifact com.azure:azure-storage-blob:jar:12.4.0
中也发现了这个问题。
我从这个 maven link 中发现了一些有趣的东西,那就是 Jar (474KB)
link 已经坏了。所以我把com.azure:azure-storage-blob:jar
版本改成了最新版本12.14.2
.
这是工作。 Azure Pipelines 可以从 Maven Central Repo 下载这个工件。