mvnw install dockerfile:build failed在插件中找不到目标“ build”

时间:2019-03-18 14:46:45

标签: maven docker

我正在尝试使用命令mvnw install dockerfile:build构建我的第一个Docker映像,但是出现以下错误:

Could not find goal 'build' in plugin org.apache.maven.plugins:maven-dependency-plugin:3.0.2 
among available ....

,并且有可用的“目标”列表。构建不存在,但是存在构建类路径,因此我尝试使用它,然后出现错误:

Could not find goal 'build-classpath' in plugin com.spotify:dockerfile-maven-plugin:1.4.9 among available goals build, help, push, tag

所以这两个命令都不起作用。我正在使用Windows,这是我的POM:

<?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>

    <groupId>org.springframework</groupId>
    <artifactId>gs-spring-boot-docker</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
   <docker.image.prefix>springio</docker.image.prefix>
    </properties>



    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>

        <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
        <execution>
        <id>default</id>
        <phase>install</phase>
        <goals>
            <goal>build</goal>
            <goal>push</goal>
        </goals>
    </execution>
    </executions>
</plugin>


         <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <version>1.4.9</version>
            <configuration>
                <repository>${docker.image.prefix}/${project.artifactId}</repository>
            </configuration>
        </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我正在使用“构建”目标的地方。怎么了?

1 个答案:

答案 0 :(得分:0)

您正在配置goals中的buildpushdockerfile-maven-plugin,它们实际上是maven-dependency-plugin上的dockerfile-maven-plugin。将这些目标降低到{{1}},然后重试。

如果尚未发生,您也可以遵循此quite basic example

相关问题