Dockerfile Maven插件:找不到插件

时间:2019-03-15 14:31:01

标签: java maven docker dockerfile maven-plugin

我想使用插件“ Dockerfile Maven”从我的项目中构建docker镜像。当我将此插件添加到我的pom.xml中时

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

我在pom的第一行出现错误:

Failure to find com.spotify:dockerfile-maven-plugin:jar:${dockerfile-maven-version} in https://
 repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the 
 update interval of central has elapsed or updates are forced

我需要配置一些东西吗?我找不到任何遇到相同问题的人。这是我的pom.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>de.leuphana</groupId>
    <artifactId>ArticleMicroService</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ArticleMicroService</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
    </properties>

2 个答案:

答案 0 :(得分:0)

您在哪里定义变量dockerfile-maven-version的值?

您应该将其添加到属性中

 <properties>
        <java.version>11</java.version>
        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
        <dockerfile-maven-version>1.4.10</dockerfile-maven-version>
 </properties>

答案 1 :(得分:0)

好像您需要在POM的部分中定义dockerfile-maven-version

添加到属性:

<dockerfile-maven-version>1.4.10</dockerfile-maven-version>