【问题标题】:Spring Boot Maven build offline when machine has no internet connectivity当机器没有互联网连接时,Spring Boot Maven 离线构建
【发布时间】:2019-02-27 17:04:19
【问题描述】:

我正在开发一个使用 Maven 的 Spring Boot 项目。问题是我需要在没有互联网连接的机器上将应用程序构建为 Jar。

我已尝试下载所有依赖项并将 .m2 文件夹从我的 Mac 复制到没有网络的机器上,但 Maven 仍然不会构建项目,因为它会引发诸如此类的错误;

mvn -o package

Non-resolveable parent POM for com.domain.visualisation: Cannot access central https://repo.maven.apache.org/maven2 in offline mode and the artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE has not bee downloaded from it before.

有没有办法在没有互联网连接的情况下让它工作?

【问题讨论】:

  • 您需要拥有所有必要的工件,包括父 pom 等。最简单的方法是使用互联网连接构建,然后将“.m2/repository”文件夹复制到所需位置并使用离线标志构建。
  • 这正是我所做的。
  • 在您的错误中,提到了工件 org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE。您是否检查过此工件是否存在?
  • 它不存在。为什么Maven没有下载它?
  • 我会再试一次。确保您在有互联网连接的机器上构建项目(如clean package),然后将项目和.m2/repository 移动到没有互联网的机器上,然后使用离线模式重试。确保两台计算机上的项目版本完全相同。

标签: maven spring-boot


【解决方案1】:

如果您确定所有依赖项都在本地 m2 文件夹中,则 _remote.repositories 文件可能是导致此错误的原因。搜索并删除本地 m2 文件夹中的每个 _remote.repositories 文件,然后再次尝试构建。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 2019-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多