37

我想将一个库部署到我公司的远程存储库。

这是我第一次想将库项目部署到远程存储库。

我收到以下错误消息:

org.sonatype.aether.transfer.ArtifactNotFoundException:在 internal.repo ( http://jenkins.internal.com/ )中找不到工件 com.http:httpkit:jar:0.0.1

也许我理解一些完全错误的东西,但是错误消息说,在远程存储库中不存在我第一次尝试部署的工件。所以当然没有这样的神器。当我尝试上传工件时,为什么 maven 会尝试获取工件?

我的pom文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.http</groupId>
<artifactId>httpkit</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>httpkit</name>

<properties>
    <platform.version> 4.1.1.4</platform.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${platform.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<!-- Deploy to internal maven repository -->
<distributionManagement>
    <repository>
      <id>internal.repo</id>
      <name>Internal Repository</name>
      <url>http://jenkins.internal.com/</url>
    </repository>
</distributionManagement>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.5.3</version>
            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory>
                <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                <sdk>
                    <platform>16</platform>
                </sdk>
               <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>

    </plugins>
</build>
</project>

我打电话

mvn 部署

从命令行

任何建议如何解决这个问题?

编辑:失败日志(运行mvn deploy -X

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    ... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
    ... 26 more
[ERROR] 
[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/MojoExecutionException
4

8 回答 8

25

您是否尝试在 settings.xml 文件中添加服务器?默认设置 xml 位于您的 ~/.m2/ 目录中。应该包含类似的内容:

<servers>
        <server>
            <id>my-internal-nexus-repo</id>
            <username>yourUserName</username>
            <password>yourPassword</password>
        </server>
</servers>

这是用于添加服务器的http://maven.apache.org/settings.html maven 文档的链接。

另一件事可能是在黑暗中开枪。我注意到您正在尝试连接到 url 建议的可能是 Jenkins 实例的内容。Jenkins 是一个持续集成服务器,对我来说似乎很奇怪你在那里找到了你的存储库。我希望有一个 Nexus 网址或其他东西。

于 2013-04-22T08:40:19.983 回答
19

(添加一个较晚的答案,希望它可以帮助那些在谷歌上寻求帮助的人......)

我也有这个问题。在拉了很多(很多)头发之后,我意识到我只是拼错了存储库名称!

所以使用OP的例子:

Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.
repo (http://jenkins.intrnal.com)

实际上可能意味着

Failed to deploy artifacts: Could not find internal.repo (http://jenkins.intrnal.com)
于 2015-06-15T13:31:29.920 回答
4

我遇到了类似的问题并解决了

  1. 在 settings.xml 中将我的 nexus 服务器添加为 nonProxyHost
  2. 将第 3 方的存储库策略设置为发布而不是快照。

在我的stackoverflow 答案中查看更多详细信息

请注意,我正在执行“mvn deploy:deploy-file”(将第 3 方工件上传到共享存储库),而您正在执行“mvn deploy”(将您的工件从构建项目上传到共享存储库),但根本原因可能相同。

于 2013-04-29T19:06:03.590 回答
4

我们遇到了这个问题。几个小时后,我们认为这是内部存储库中的磁盘空间问题。

于 2019-08-01T20:38:25.723 回答
1

关于错误:

Failed to deploy artifacts: Could not transfer artifact

解决方案:

解决此问题的一种非常简单的方法是更改​​/更新pom.xml文件中的版本。假设 01.16.03 已被使用,然后尝试改用 01.16.04。它应该工作。

于 2020-10-30T11:17:57.880 回答
1

在我的情况下,我在 pom.xml 的 snapshotRepository 部分中的服务器 url 指向 http,而我的内部存储库托管在 https 中。

于 2016-05-27T04:45:35.380 回答
0

好的...几天前我遇到了同样的问题。在摆弄了各种排列组合之后,我终于得出了结论。那些说反应堆会自动排序并自行解决所有依赖关系的人是不正确的。似乎下面的链接描述了这一切。请看“反应堆排序”部分下的最后一点:

https://maven.apache.org/guides/mini/guide-multiple-modules.html#Reactor_Sorting

它建议在没有其他规则适用的情况下考虑定义模块的顺序。

我希望这对其他人有所帮助。:)

于 2018-03-22T17:23:23.143 回答
0

这是因为您的 Maven 无法找到设置文件。如果删除 .m2 不起作用,请尝试以下解决方案

转到您的 JOB 配置

比构建部分

添加构建步骤:- 调用顶级 Maven 目标并填写 Maven 版本和目标

比单击高级按钮并提及图像中提及的设置文件路径 在此处输入图像描述

于 2020-08-26T13:55:33.493 回答