Spring Cloud(2) |No plugin found for prefix 'docker' in the current project and in the plugin groups - Java & Basketball - CSDN博客

用docker部署Spring Cloud项目的时候,运行命令:

mvn package docker:build

报如下错误:

Downloading: https://nexus.superdesk.cn/repository/maven-public/org/codehaus/mojo/maven-metadata.xml
Downloading: https://nexus.superdesk.cn/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml
Downloaded: https://nexus.superdesk.cn/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 43.8 KB/sec)
Downloaded: https://nexus.superdesk.cn/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 65.4 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.083 s
[INFO] Finished at: 2019-04-16T19:07:31+08:00
[INFO] Final Memory: 25M/387M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'docker' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/linjinyu/.m2/repository), nexus (https://nexus.superdesk.cn/repository/maven-public/)] -> [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/NoPluginFoundForPrefixException

Process finished with exit code 1

pom.xml中文件是:

<build>
        <finalName>${project.artifactId}</finalName>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${compiler.jdk.version}</source>
                    <target>${compiler.jdk.version}</target>
                    <encoding>${output.encoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                    <dockerHost>http://127.0.0.1:2375</dockerHost>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>

        </plugins>
    </build>

检查pom文件没有任何问题,最后发现在maven的conf/setting.xml中要加入:

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

然后再运行mvn package docker:build, 就OK了!

参照我在stackoverflow上的回答:https://stackoverflow.com/questions/47301470/no-plugin-found-for-prefix-docker-in-the-current-project-and-in-the-plugin-gro


Original url: Access
Created at: 2019-04-16 19:09:03
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论