运行Sonatype Nexus插件

时间:2017-05-02 14:59:43

标签: java maven sonatype

我正在尝试运行部署以将Maven插件推送到Nexus存储库,但出于某种原因,我不断遇到一个相当奇怪的异常:Maven抱怨org.apache.http.util.Args丢失了。这特别奇怪,因为插件本身似乎并不直接依赖于org.apache.http包,即使它传递(更有可能),相关包也存在于我的存储库中。

我没有对插件使用任何特殊配置,只是guide中的最小配置。完整的堆栈跟踪,由Maven提供:

Caused by: java.lang.NoClassDefFoundError: org/apache/http/util/Args
        at org.apache.http.auth.UsernamePasswordCredentials.<init>(UsernamePasswordCredentials.java:78)
        at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.applyAuthenticationIfAny(NexusClientFactoryImpl.java:245)
        at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.doCreateHttpClientFor(NexusClientFactoryImpl.java:136)
        at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.createFor(NexusClientFactoryImpl.java:125)
        at org.sonatype.nexus.maven.staging.remote.RemoteNexus.createNexusClient(RemoteNexus.java:189)
        at org.sonatype.nexus.maven.staging.remote.RemoteNexus.<init>(RemoteNexus.java:102)
        at org.sonatype.nexus.maven.staging.deploy.strategy.AbstractStagingDeployStrategy.createRemoteNexus(AbstractStagingDeployStrategy.java:54)
        at org.sonatype.nexus.maven.staging.deploy.strategy.StagingDeployStrategy.deployPerModule(StagingDeployStrategy.java:70)
        at org.sonatype.nexus.maven.staging.deploy.DeployMojo.execute(DeployMojo.java:192)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.util.Args
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 31 more

我的pom.xml中的插件配置:

<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>1.6.8</version>
  <extensions>true</extensions>
  <configuration>
    <serverId>ossrh</serverId>
    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
    <autoReleaseAfterClose>false</autoReleaseAfterClose>
  </configuration>
</plugin>

提前感谢您的任何建议!

1 个答案:

答案 0 :(得分:0)

如果其他人遇到问题,很可能因为该项目不使用Apache HTTP,您可以通过编辑POM将依赖项直接注入插件:

<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.8</version>
    <extensions>true</extensions>
    <configuration>
        <serverId>ossrh</serverId>
        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
        <autoReleaseAfterClose>false</autoReleaseAfterClose>
    </configuration>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.6</version>
        </dependency>
    </dependencies>
</plugin>

请注意用于直接注入HTTP内核的特定于插件的依赖项解析。