Ric*_*cki 6 java pom.xml maven docker spring-boot
我\xe2\x80\x99m 尝试从我的 DockerFile 构建 Docker 映像,但不断收到错误,好像无法找到父级来pom.xml在 docker 文件中执行 Maven 命令并构建项目。\n我一直在四处寻找并您会看到人们所做的就是向子项添加pom.xml对父项 pom.xml 的引用,您尝试relativePath>.. /pom.xml/relativePath>向子项添加 a ,但仍然不起作用。
[![项目结构[1]](https://i.stack.imgur.com/koK4I.png)
FROM alpine/git as clone\nWORKDIR /app\nRUN git clone https://github.com/RicardoVargasLeslie/manager.git\n\nFROM openjdk:8-jdk-alpine as build\nWORKDIR /workspace/app\n\nCOPY mvnw .\nCOPY .mvn .mvn\nCOPY pom.xml .\nCOPY src src\n\nRUN ./mvnw install -DskipTests\n\nENTRYPOINT ["java","-jar","/Web-0.0.1-SNAPSHOT.jar"]\nRun Code Online (Sandbox Code Playgroud)\n\n<project xmlns="http://maven.apache.org/POM/4.0.0"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n <modelVersion>4.0.0</modelVersion>\n <parent>\n <groupId>com.imricki.manager</groupId>\n <artifactId>core</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <relativePath>../pom.xml</relativePath>\n </parent>\n <artifactId>Web</artifactId>\n <name>Web</name>\n <description>Web Module</description>\nRun Code Online (Sandbox Code Playgroud)\n\n<?xml version="1.0" encoding="UTF-8"?>\n<project xmlns="http://maven.apache.org/POM/4.0.0"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n <modelVersion>4.0.0</modelVersion>\n <parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.1.6.RELEASE</version>\n <relativePath /> <!-- lookup parent from repository -->\n </parent>\n <groupId>com.imricki.manager</groupId>\n <artifactId>core</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>Core</name>\n <description>Core Module</description>\n <packaging>pom</packaging>\nRun Code Online (Sandbox Code Playgroud)\n\ndocker build -t rest-api .\nRun Code Online (Sandbox Code Playgroud)\n\n$ docker build -t rest-api .\nSending build context to Docker daemon 42.92MB\nStep 1/11 : FROM alpine/git as clone\n ---> a1d22e4b51ad\nStep 2/11 : WORKDIR /app\n ---> Using cache\n ---> e53f5b4941b5\nStep 3/11 : RUN git clone https://github.com/RicardoVargasLeslie/manager.git\n ---> Using cache\n ---> 490b2afea22c\nStep 4/11 : FROM openjdk:8-jdk-alpine as build\n ---> a3562aa0b991\nStep 5/11 : WORKDIR /workspace/app\n ---> Using cache\n ---> 0b7c106319e9\nStep 6/11 : COPY mvnw .\n ---> Using cache\n ---> 2c7ab0b79d25\nStep 7/11 : COPY .mvn .mvn\n ---> Using cache\n ---> eb9ec36b737a\nStep 8/11 : COPY pom.xml .\n ---> Using cache\n ---> 2296a5fbd6ae\nStep 9/11 : COPY src src\n ---> Using cache\n ---> 022a609f4376\nStep 10/11 : RUN ./mvnw install -DskipTests\n ---> Running in 897cff2e3c3b\n[INFO] Scanning for projects...\n[ERROR] [ERROR] Some problems were encountered while processing the POMs:\n[FATAL] Non-resolvable parent POM for com.imricki.manager:Web:[unknown-version]: Could not find artifact com.imricki.manager:core:pom:0.0.1-SNAPSHOT and \'parent.relativePath\' points at wrong local POM @ line 5, column 10\n @\n[ERROR] The build could not read 1 project -> [Help 1]\n[ERROR]\n[ERROR] The project com.imricki.manager:Web:[unknown-version] (/workspace/app/pom.xml) has 1 error\n[ERROR] Non-resolvable parent POM for com.imricki.manager:Web:[unknown-version]: Could not find artifact com.imricki.manager:core:pom:0.0.1-SNAPSHOT and \'parent.relativePath\' points at wrong local POM @ line 5, column 10 -> [Help 2]\n[ERROR]\n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR]\n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException\n[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException\nThe command \'/bin/sh -c ./mvnw install -DskipTests\' returned a non-zero code: 1\nRun Code Online (Sandbox Code Playgroud)\n\n我\xe2\x80\x99m 不确定出了什么问题或如何使构建工作,感谢您的帮助。
\nMaven 是一种工具,它支持以声明方式管理项目的依赖项。它通过标准化项目共享 jar 和 pom 文件(工件)的方式来实现这一点,并使用 Maven 坐标来声明项目依赖项(groupId、artifactId 和版本),然后在 jar 和 pom 文件的大型公共 Maven 存储库中查找这些依赖项称为 Maven 中心。
为了将您的 jar/pom 文件(例如您的核心)作为 Maven 工件进行管理,您需要将您的工件部署到 Maven Central(任何人都可以访问的公共存储库)或私有网络中某个位置的私有存储库(或者甚至在互联网上,并且可能需要身份验证)。对于私有存储库,您需要包含您的私有存储库,以便您的 Maven 执行不仅在 Maven Central 中查找工件,而且还在您的私有存储库中查找工件。您可以通过将以下内容添加到settings.xml文件中来实现此目的:
<!-- Authentication here -->
<servers>
<server>
<id>nexus</id>
<username>some_username</username>
<password>some_passowrd</password>
</server>
</servers>
...
<profiles>
<profile>
<id>nexus</id>
<!--Override the repository (and pluginRepository) "central" from the
Maven Super POM -->
<repositories>
<repository>
<id>nexus-release</id>
<name>nexus-release</name>
<url>http://hostname_or_ip_address/content/repositories/releases</url>
</repository>
<repository>
<id>nexus-thirdparty</id>
<name>nexus-thirdparty</name>
<url>http://hostname_or_ip_address/content/repositories/thirdparty</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-plugin-release</id>
<name>nexus-plugin-release</name>
<url>http://hostname_or_ip_address/content/repositories/releases/</url>
</pluginRepository>
<pluginRepository>
<id>nexus-plugin-third-party</id>
<name>nexus-plugin-third-party</name>
<url>http://hostname_or_ip_address/content/repositories/thirdparty/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
...
Run Code Online (Sandbox Code Playgroud)
我注意到您的子pom.xml文件引用了自定义父模块。您需要确保您的父模块位于 Maven 存储库 (Nexus/Artifactory) 中,并且您提供一个settings.xml包含存储库设置的文件,以便 Docker 容器能够拉取父 pom。
| 归档时间: |
|
| 查看次数: |
5998 次 |
| 最近记录: |