首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven无法使用强制身份验证从HTTPS Nexus下载工件

Maven无法使用强制身份验证从HTTPS Nexus下载工件
EN

Stack Overflow用户
提问于 2012-05-15 21:04:25
回答 2查看 15.4K关注 0票数 5

我有一个可通过HTTPS获得的Nexus。只有授权用户才有权访问它。使用Maven,当所有需要的工件都在本地repo中时,我甚至可以部署构建工件。但是,当我从本地存储库中删除一些必需的工件时,构建失败。

代码语言:javascript
复制
Downloading: https://example.com/nexus/content/groups/all/org/springframework/spring-test-mvc/1.0.0.BUILD-SNAPSHOT/spring-test-mvc-1.0.0.BUILD-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] example - project1 ..................................... SUCCESS [0.500s]
[INFO] example - project2 ..................................... FAILURE [2.951s]
[INFO] example - project3 ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.599s
[INFO] Finished at: Tue May 15 13:58:13 EEST 2012
[INFO] Final Memory: 6M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project example - project2: Could not resolve dependencies for project com.example:example-project:jar:1.2.0-SNAPSHOT: Failed to collect dependencies for [com.example:example-project:jar:1.2.0-SNAPSHOT (compile), org.springframework:spring-beans:jar:3.1.1.RELEASE (compile), org.springframework:spring-context:jar:3.1.1.RELEASE (compile), org.springframework:spring-core:jar:3.1.1.RELEASE (compile), org.springframework:spring-test:jar:3.1.1.RELEASE (test), org.springframework:spring-web:jar:3.1.1.RELEASE (compile), org.apache.httpcomponents:httpclient:jar:4.1.1 (test), org.codehaus.jackson:jackson-mapper-asl:jar:1.9.6 (compile), org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT (test), junit:junit:jar:4.10 (test), org.mockito:mockito-all:jar:1.9.0 (test), org.hamcrest:hamcrest-all:jar:1.1 (compile), org.slf4j:slf4j-api:jar:1.6.1 (compile), org.slf4j:slf4j-log4j12:jar:1.6.1 (compile), log4j:log4j:jar:1.2.16 (compile), log4j:apache-log4j-extras:jar:1.1 (compile)]: Failed to read artifact descriptor for org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT: Could not transfer artifact org.springframework:spring-test-mvc:pom:1.0.0.BUILD-SNAPSHOT from/to nexus (https://example.com/nexus/content/groups/all): Not authorized, ReasonPhrase:Unauthorized. -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :grc-webclient-services

我的用户的settings.xml中有以下内容:

代码语言:javascript
复制
<settings>
<pluginGroups>
    </pluginGroups>
    <proxies>
    </proxies>
    <mirrors>
      <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>https://example.com/nexus/content/groups/all</url>
      </mirror>
    </mirrors>

    <profiles>
        <profile>

            <id>nexus</id>

            <properties>
                <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonardb?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>
                <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
                <sonar.jdbc.username>sonarusername</sonar.jdbc.username>
                <sonar.jdbc.password>sonarpw</sonar.jdbc.password>
                <sonar.host.url>http://localhost:9000/</sonar.host.url>
            </properties>


            <repositories>
                <repository>
                    <id>central</id>
                    <url>https://example.com/nexus/content/groups/all</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>https://example.com/nexus/content/groups/all</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>

        </profile>
    </profiles>

    <servers>
        <server>
            <id>all</id>
            <username>user</username>
            <password>pw</password>
        </server>
        <server>
            <id>releases</id>
            <username>user</username>
            <password>pw</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>user</username>
            <password>pw</password>
        </server>
    </servers>

    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>

</settings>

当我使用wget从这个Nexus下载工件时,我必须添加--no-check-certificate密钥来跳过服务器的证书(因为它是自签名的),然后我可以使用wget下载它。

我找到了Java -Dsun.security.ssl.allowUnsafeRenegotiation=true,,但它根本没有改变任何东西。

之后,我发现这可能不是自签名证书问题,因为我使用以下命令将服务器的证书添加到信任列表中:

代码语言:javascript
复制
keytool -keystore $JAVA_HOME/jre/lib/security/cacerts -import -file certificate.cer

有人知道如何在构建时从Nexus下载工件吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-16 06:00:55

我不得不改变

代码语言:javascript
复制
<server>
    <id>all</id>
    <username>user</username>
    <password>pw</password>
</server>

代码语言:javascript
复制
<server>
    <id>nexus</id>
    <username>user</username>
    <password>pw</password>
</server>

其中'nexus‘是我在settings.xml顶部的镜像的标识符。

票数 6
EN

Stack Overflow用户

发布于 2013-06-10 19:05:43

添加旅行车-http-轻量级扩展,很好的解释

Best solution to maven proxy configure

票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10601297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档