如何提前下载所有依赖包?

2024-01-10

我正在编写一个circleci 脚本,我想一次性解决所有依赖关系,因为我计划在这个脚本中多次运行maven。我想让它尽可能快,我注意到 Maven 仍然会下载 poms,即使它具有最新的依赖项。

为了避免下载 poms,我将 ran maven 与-o, 离线模式。但这导致了没有依赖项的错误。然后我运行这个命令来提前下载依赖项和插件:

mvn dependency:resolve dependency:resolve-plugin

但是在我运行之后,如果我立即运行

mvn -o test

然后我得到一个错误。错误是这样说的:

[错误] 无法在项目 MyProject 上执行目标 org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources):执行目标 org.apache.maven.plugins:maven-resources 的默认资源-plugin:2.6:resources failed: 插件 org.apache.maven.plugins:maven-resources-plugin:2.6 或其依赖项之一无法解析:无法解析以下工件:org.apache.maven:maven-配置文件:jar:2.0.6,org.apache.maven:maven-repository-metadata:jar:2.0.6,org.apache.maven:maven-plugin-registry:jar:2.0.6,classworlds:classworlds:jar: 1.1-alpha-2:无法访问中央(https://repo.maven.apache.org/maven2 https://repo.maven.apache.org/maven2)在离线模式下,并且之前尚未从其中下载工件 org.apache.maven:maven-profile:jar:2.0.6 。

如果我在本地构建项目mvn test,效果很好。如果我运行一个mvn package在 Circleci 上而不是mvn dependency:resolve dependency:resolve-plugin,效果很好。

如果我提前下载了所有依赖项和插件,为什么会出现上述错误?我该如何解决这个问题?

这是我的 pom:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.app.common</groupId>
    <artifactId>app</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>app Rest</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>maven2-repository.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.26</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet-core -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.26</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.26</version>
            <exclusions>
                <exclusion>
                    <artifactId>javax.annotation-api</artifactId>
                    <groupId>javax.annotation</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jersey-media-jaxb</artifactId>
                    <groupId>org.glassfish.jersey.media</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>2.26</version>
            <exclusions>
                <exclusion>
                    <artifactId>osgi-resource-locator</artifactId>
                    <groupId>org.glassfish.hk2</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.annotation-api</artifactId>
                    <groupId>javax.annotation</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>2.9.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-jaxrs-base</artifactId>
                    <groupId>com.fasterxml.jackson.jaxrs</groupId>
                </exclusion>
            </exclusions>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jaxb-annotations -->
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
            <version>2.9.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.26</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.ext/jersey-entity-filtering -->
        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-entity-filtering</artifactId>
            <version>2.26</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.codehaus.jettison/jettison -->
        <dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
            <version>1.3.8</version>
            <exclusions>
                <exclusion>
                    <artifactId>stax-api</artifactId>
                    <groupId>stax</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.45</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.maxmind.db/maxmind-db -->
        <dependency>
            <groupId>com.maxmind.db</groupId>
            <artifactId>maxmind-db</artifactId>
            <version>1.2.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.maxmind.geoip2/geoip2 -->
        <dependency>
            <groupId>com.maxmind.geoip2</groupId>
            <artifactId>geoip2</artifactId>
            <version>2.10.0</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-codec</artifactId>
                    <groupId>commons-codec</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.8</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.4.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/javax.inject -->
        <dependency>
            <groupId>org.glassfish.hk2.external</groupId>
            <artifactId>javax.inject</artifactId>
            <version>2.5.0-b60</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-hk2 -->
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>2.26</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-api -->
        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-api</artifactId>
            <version>2.5.0-b60</version>
            <exclusions>
                <exclusion>
                    <artifactId>aopalliance-repackaged</artifactId>
                    <groupId>org.glassfish.hk2.external</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.inject</artifactId>
                    <groupId>javax.inject</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-utils -->
        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-utils</artifactId>
            <version>2.5.0-b60</version>
            <exclusions>
                <exclusion>
                    <artifactId>javax.inject</artifactId>
                    <groupId>javax.inject</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.annotation-api</artifactId>
                    <groupId>javax.annotation</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-locator -->
        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-locator</artifactId>
            <version>2.5.0-b60</version>
            <exclusions>
                <exclusion>
                    <artifactId>javassist</artifactId>
                    <groupId>org.javassist</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>aopalliance-repackaged</artifactId>
                    <groupId>org.glassfish.hk2.external</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.annotation-api</artifactId>
                    <groupId>javax.annotation</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.0.Final</version>
        </dependency>


    </dependencies>

    <build>
        <finalName>app Rest</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

尝试用

mvn dependency:go-offline

依赖:离线 全名:

org.apache.maven.plugins:maven-dependency-plugin:3.0.2:脱机

描述:

解决所有项目依赖关系的目标,包括插件和 报告及其依赖性。

但是,在您应该将依赖项和编译器插件的版本设置到您的 pom 中之前:

<plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
         <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.0.2</version>
        </plugin>
    </plugins>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何提前下载所有依赖包? 的相关文章

  • JSF2.0 中的空白输入字段未设置为 NULL

    我有一个支持 bean 其中 fileld 为 Long Double Integer String 当我没有在输入字段中指定任何内容时 长整型 整数和双精度值将被视为零 而不是空 我正在使用 tomcat 来部署我的应用程序 有什么解决办
  • 序列化 ArrayList

    我正在尝试编写一个 Android 游戏 即使用户想要返回主菜单或者活动被系统终止 我也希望能够暂停游戏 onSaveInstanceState 似乎并没有给我很大的控制权来决定何时可以读回捆绑包 而且据我所知 捆绑包仅在短时间内有效 所以
  • 如何打印JTable中选定的行

    我尝试使用主 JTable 的选定行和相同的头和单元格渲染来创建临时 JTable 但是当我尝试打印它时 我只得到一个带有线边框的空矩形 我在如何打印 JTable 的特定行 列 https stackoverflow com questi
  • 使用 s:select 标签在下拉菜单中使用 i18n [重复]

    这个问题在这里已经有答案了 我的 JSP 页面中有一个下拉菜单 它是通过
  • 在 Gradle 中运行自定义测试任务而无需重新编译

    我有一个 Gradle 自定义测试任务来运行我的集成测试 我希望能够在 Gradle 不自动完成之前的所有阶段并仅运行测试的情况下运行它 有没有办法在每个构建步骤不使用 x 的情况下执行此操作 None
  • 在 JList 中写一些东西

    嘿 我还有另一个问题 我创建JList在我的主窗口中 现在我想向其中添加一些内容 我这样做 private void jButton2ActionPerformed java awt event ActionEvent evt Dodaj
  • 图像在 3D 空间中绕 Y 轴旋转

    我有一个 BufferedImage 我想用 theta 角而不是仿射变换绕 Java 中的 Y 轴旋转图像 图片 旋转将如下图所示 矩形将是图像 我可以通过旋转图像的每个像素并绘制图像来做到这一点 因为我必须旋转很多图像 所以我认为这不是
  • TableModel setCellEditable 并自动将值设置回 false

    我目前正在尝试在 JTable 中实现 JPopupMenu 它允许解锁单元格以进行编辑 Override public void actionPerformed ActionEvent e if e getActionCommand Un
  • 使用 Copy.CopyIntoItems Web 服务将文件上传到 SharePoint 2010 时收到 400 错误请求

    SharePoint 新手 我尝试使用 Java 的 CopyIntoItems Web 服务方法将文档上传到 SharePoint 但不断收到 400 错误请求 我使用 Java 的 wsimport 从 wsdl 文件生成类文件 这是我
  • 如何防止我的 servlet 被其他网站调用

    好的 我有一个像这样的简单的 servlet public class SimpleServlet extends HttpServlet public void doPost HttpServletRequest req HttpServ
  • 相对重力

    我最近开始使用jMonkey引擎 这非常好 但我在尝试实现相对重力时陷入了困境 我想让行星彼此围绕轨道运行 不一定是完美的圆形轨道 取决于速度 所以每个对象都应该影响其他对象 我现在拥有的 关闭全球重力 bulletAppState get
  • 如何在不冒 StackOverflowError 风险的情况下使用 CompletableFuture?

    我想遍历异步函数的搜索空间 我将逻辑编码如下 Assuming that a function maps a range of inputs to the same output value minimizes the input valu
  • Java中如何将Object[]转换为String[]?

    我有一个关于 Java 的问题 我有一个Object Java默认的 不是用户定义的 我想将它转换为String 谁能帮我 谢谢 这是转换 for int i 0 i lt objectArr length i try strArr i o
  • Spring Boot 中的服务限流能力

    有什么办法可以实现Spring中其余服务的服务限制能力 特别是Spring boot 这里的期望是 我的服务暴露于外界 目前每秒 分钟的服务调用数量没有限制 我们希望通过设置限制来控制这一点 我有一个替代选项 通过跟踪并发哈希映射或任何缓存
  • Java泛型类型参数中的问号是什么意思? [复制]

    这个问题在这里已经有答案了 这是取自斯坦福解析器附带的一些示例的一小段代码 我已经用 Java 进行了大约 4 年的开发 但从未对这种风格的代码应该表示什么有非常深入的理解 List
  • java.lang.IllegalStateException:FragmentManager 已被销毁

    活动中onResume我称之为 volley request 的方法 它获取项目列表 然后将它们加载到此活动内的 ListFragment 中 当我第一次进入活动时 一切正常 但当我重新进入活动时 ListFragment 为空 并且控制台
  • 如何预先填充 JFileChooser 将“文件名”?

    我打算用数据库中的名称填充 JFileChooser 但使用标准 JFileChooser 对话框进行加载 删除 保存和另存为 我想给用户留下这样的印象 他们正在处理文件系统 而在后端使用数据库来保存更改 用户不应该能够浏览到不同的目录进行
  • 找出对象列表中是否包含具有指定字段值的内容?

    我有一个从数据库收到的 DTO 列表 它们有一个 ID 我想确保我的列表包含具有指定 ID 的对象 显然 在这种情况下创建具有预期字段的对象不会有帮助 因为 contains 调用 Object equals 并且它们不会相等 我想出了这样
  • 当框架被拖动时,如何设置 JWindow 的位置位于文本字段下方?

    我正在制作一个自动完成项目 就像谷歌一样 我的框架中有一个 jtextfield 每当我在该字段中输入内容时 该文本字段下方就会出现一个 JWindow 并且该窗口来自另一个类 现在的问题是 每当我拖动框架时 如何使窗口始终出现在文本字段下
  • 如何将元素添加到通用集合

    我想知道如何将专用对象添加到通用集合中 我正在使用以下代码 Collection

随机推荐