Search code examples
dockerspring-bootmaven-3spring-cloud

No plugin found for prefix 'docker' in the current project and in the plugin groups


deploy Spring Cloud project with docker, some code in the 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>

when i execute the command: mvn package docker:build, it throws the above errors:

    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/)]

how to solve it?


Solution

  • add the below code to your maven conf/setting.xml

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

    if you want to get more detail, pls refer to https://github.com/spotify/docker-maven-plugin/issues/322