当前位置: 首页 > 知识库问答 >
问题:

无法执行目标com。spotify:dockerfile maven插件:1.3.6:基于项目“foo”生成:无法生成映像:

龚弘业
2023-03-14

我们在4人的小团队中工作。我们使用docker来部署我们的服务。其中一个服务是java Spring Boot项目,它是在使用maven构建docker映像后部署的。要制作Spring Boot服务的docker映像,我们使用mvn清洁包dockerfile: build

有趣的是,我的同事在建立SpringBoot服务的docker形象方面没有问题。我得到了maven的错误信息:

[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default-cli) on project 'foo': Could not build image: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('osxkeychain')

我试图从中删除所有maven存储库。m2/存储库,重新启动docker并删除所有图像。

后来我尝试在两个单独的命令中运行mvn clean package dockerfile:build

  • mvn包,然后
  • mvn docker: build

mvn包已通过,并且mvn docker:build失败,错误与上述相同。

Maven版本3.5.4,Docker版本18.06.1-ce,版本e68fc7a,操作系统:macOS mojave

我甚至试着重新启动我的电脑,希望它能修复它。。。

编辑:这里是maven pom插件dockerfile-maven-plugin

...
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.3.6</version>
    <configuration>
        <repository>${project.artifactId}</repository>
    </configuration>
</plugin>
...

编辑2:

完整错误消息:

[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default) on project spring-boot-service: Could not build image: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('swarm')
[ERROR]  at [Source: N/A; line: -1, column: -1] (through reference chain: java.util.LinkedHashMap["stackOrchestrator"])
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

编辑3:

docker-compose.yml

wrapper:
  image: spring-boot-service:latest
ports:
  - "8080:8080"
expose:
  - "8080"
links:
  - db
  - another-service

已解决:

在我的例子中,这是错误版本的DockerfileMaven插件。我使用了1.3.6,并且1.4.7修复了这个问题。

多亏了鲍里斯!

更新:还有一件事!

确保mvnfinishbuild命名正确,例如:

[INFO] Successfully built **spring-boot-service:0.0.1-SNAPSHOT**

docker-compose.yml应该是这样的:

...
wrapper:
  image: **spring-boot-service:0.0.1-SNAPSHOT**
...

共有1个答案

李法
2023-03-14

以下是dockerfile maven插件配置:

<plugin>
  <groupId>com.spotify</groupId>
  <artifactId>dockerfile-maven-plugin</artifactId>
  <version>${dockerfile-maven-plugin.version}</version>
  <executions>
    <execution>
      <id>default</id>
      <goals>
        <goal>build</goal>
        <goal>push</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <repository>${project.artifactId}</repository>
    <tag>${project.version}</tag>
    <buildArgs>
      <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
    </buildArgs>
  </configuration>
</plugin>

注意:使用最新发布的版本1.4.7

这将配置插件来构建和推送您的图像,只需一个命令:

$ mvn clean deploy

如果只想构建Docker映像,请运行:

$ mvn clean package
 类似资料:
  • org.gradle.api.ProjectConfigurationException:配置项目“:App”时出现问题。在

  • 我是Android Studio的新手。我试图建立项目在Android Studio(使项目)和它显示我: 未能完成梯度执行。 原因:无法启动守护进程。此问题可能是由守护程序的不正确配置引起的。例如,使用无法识别的jvm选项。请参阅http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html守护进程的用户指南章节。请阅读以下进程输出以了解更多信

  • 将文件选取器^1.13.3添加到“我的依赖项”后,项目无法生成此错误 失败:构建失败,但有例外。 错误:任务执行失败:app:mergeDebugJavaResource 执行com.android.build.gradle.internal.tasks.时发生故障$ActionFacade文件'com.android.builder.files.ZipCentralDirectory@7dfb7

  • [错误]生成无法读取1个项目->[帮助1][错误] [错误]项目com.example.angularjs:demo:0.0.1-快照(C:\users\vvk\download\demo\POM.xml)有1个错误[错误] com.example.angularjs:demo:0.0.1-快照:无法解析的父POM:无法传输项目org.springframework.boot:spring-boo

  • 我创建了一个maven项目,其中包含测试用例及其相应的功能。验证检查的所有功能都放在src/main/java下。测试用例也是src/test/java的一部分。我已经把log4j放在下面了。src/main/resources中的属性。 此外,在每个类文件中,我添加了以下行以及以下导入: 日志的初始化: 并且使用创建日志。 还有,在pom中。xml,添加了以下依赖项: 但是我看到日志没有在控制台

  • 我得到以下指定错误, 错误:(115)***Android NDK:正在中止。停下来。错误:执行任务“:un7zip:CompileReleAsendk”失败。 com.android.ide.common.process.processException:使用参数{ndk_project_path=null app_build_script=e:\apprizort\rizortCardboar