【问题标题】:No plugin found for prefix 'docker' in the current project and in the plugin groups在当前项目和插件组中找不到前缀“docker”的插件
【发布时间】:2018-04-28 07:51:45
【问题描述】:

使用docker部署Spring Cloud项目,pom.xml中的一些代码:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!-- tag::plugin[] -->
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
        <!-- end::plugin[] -->
    </plugins>
</build>

当我执行命令时:mvn package docker:build,它会抛出上述错误:

    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 5.7 KB/sec)
    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 7.3 KB/sec)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] eureka-server ...................................... SUCCESS [ 26.279 s]
    [INFO] service-1 ......................................... SUCCESS [ 14.649 s]
    [INFO] demo1 ........................................... FAILURE [  2.850 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 45.535 s
    [INFO] Finished at: 2017-11-15T14:28:05+08:00
    [INFO] Final Memory: 47M/532M
    [INFO] ------------------------------------------------------------------------
    [ERROR] No plugin found for prefix 'docker' in the current project 
and in the plugin groups [org.sonatype.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/../Repository), nexus (http://3.2.4.2:8888/repository/maven-public/)]

如何解决?

【问题讨论】:

    标签: docker spring-boot maven-3 spring-cloud


    【解决方案1】:

    如果您使用的是 dockerfile maven 插件,则需要将 docker:build 更改为 dockerfile:build 和 docker:push 到 dockerfile:push

    【讨论】:

      【解决方案2】:

      对我来说以不同的方式工作,如果您遵循 maven 插件模式 {prefix}-maven-plugin... 在本例中为 dockerfile-maven-plugin,您应该能够使用:mvn package dockerfile:build 运行它。 我正在使用 Maven:3、Spring Boot 2 和 Docker maven 插件 1.3.4

      【讨论】:

      • 这是什么意思?使用maven插件模式在哪里?
      【解决方案3】:

      将以下代码添加到你的maven conf/setting.xml

      <pluginGroups>  
          <pluginGroup>com.spotify</pluginGroup>  
      </pluginGroups>
      

      如需了解更多详情,请参考https://github.com/spotify/docker-maven-plugin/issues/322

      【讨论】:

        猜你喜欢
        • 2016-07-09
        • 1970-01-01
        • 2014-08-10
        • 2019-08-09
        • 2016-04-18
        • 2017-06-02
        • 2015-08-31
        • 2016-12-28
        • 2017-01-31
        相关资源
        最近更新 更多