【发布时间】: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