【问题标题】:Unable to deploy jar from a Spring Boot application to Nexus/Artifactory无法将 jar 从 Spring Boot 应用程序部署到 Nexus/Artifactory
【发布时间】:2017-06-24 19:32:51
【问题描述】:

使用 maven 部署到我的本地 artifactory/nexus 可以很好地用于示例 Spring Boot 应用程序(在 start.spring.io 上生成):

mvn clean package deploy

但是,一旦我将 org.springframweork.cloud 的依赖项添加到我的 pom 中:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-zipkin</artifactId>
    </dependency>

然后部署失败并在客户端出现“连接重置”。 artifactory.log 显示

2017-02-07 12:57:59,788 [http-nio-8081-exec-10] [INFO ] (o.a.e.UploadServiceImpl:516) - Deploy to 'snapshot-local:com/test/artifactory-demo/0.0.1-SNAPSHOT/artifactory-demo-0.0.1-20170207.125744-10.jar' Content-Length: 21658959
2017-02-07 12:58:03,256 [http-nio-8081-exec-10] [WARN ] (o.a.w.s.RepoFilter  :222) - Sending HTTP error code 404: Failed to read stream: Unexpected EOF read on the socket
2017-02-07 12:58:59,540 [http-nio-8081-exec-2] [WARN ] (o.a.w.s.RepoFilter  :222) - Sending HTTP error code 404: Failed to read stream: null

我注意到 Nexus 有类似的行为。如果我尝试使用 Artifactory UI 上传 jar,我也会遇到同样的错误。如果我使用以下方法提取 jar 文件,那就够有趣了:

jar xf demo.jar

然后再次将其压缩回去更改标志将标志更改为“cf”然后这个新打包的jar可以成功上传到Artifactory。看起来 Maven 在构建步骤中对 jar 做了一些有趣的事情。有谁知道我做错了什么?在部署之前必须提取并重新打包 jar 远非理想,尤其是我想使用 Jenkins 自动为许多项目执行此操作。

下面是整个不工作的 pom.xml:

<?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.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>artifactory-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>artifactory-demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jfrog.artifactory.client</groupId>
            <artifactId>artifactory-java-client-services</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.M1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <name>snapshots</name>
            <url>http://artifactory.server.ip:8079/artifactory/snapshot-local</url>
        </snapshotRepository>
    </distributionManagement>
</project>

【问题讨论】:

  • 可能是由全局 JAR 文件大小引起的。您无法上传的 JAR 的大小(以 MB 为单位)是多少?
  • 它是 31MB,但正如我所说:如果我提取 jar 并再次压缩它,大小保持不变,但上传成功完成。我还尝试将大型随机文本文件添加到 jar 并上传这些文件。这也很好用,所以我认为大小不是问题。

标签: maven spring-boot nexus spring-cloud artifactory


【解决方案1】:

事实证明,我们的本地基础架构出现了一个奇怪的问题。服务器只是断开了连接,所以我暂时将我的 Nexus 与我们的 CI 应用程序放在同一台机器上

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-13
    • 2020-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 2018-12-31
    • 2021-07-25
    相关资源
    最近更新 更多