崔志伟博客

使用fabric8-maven-plugin插件的错误处理(No plugin found for prefix 'fabric8')

使用maven插件fabric8-maven-plugin部署springboot应用到kubernetes时遇到构建失败的问题,错误信息是No plugin found for prefix ‘fabric8’ in the current project,通过修改maven的settings.xml解决问题,在此做个记录:

环境信息

  1. 操作系统:CentOS Linux release 7.6.1810
  2. Kubernetes:1.14.0
  3. Java:1.8.0_191
  4. Maven:3.6.0
  5. fabric8-maven-plugin插件:3.5.37

错误出现

构建部署命令如下:

mvn clean package fabric8:deploy -Pkubernetes

执行上述命令后,构建失败,错误信息如下:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Spring Cloud Kubernetes :: Examples 1.1.0.BUILD-SNAPSHOT:
[INFO] 
[INFO] Spring Cloud Kubernetes :: Examples ................ SKIPPED
[INFO] Spring Cloud Kubernetes :: Examples :: Reload ConfigMap SKIPPED
[INFO] Spring Cloud Kubernetes :: Examples :: Hello World . SKIPPED
[INFO] Spring Cloud Kubernetes :: Examples :: Leader Election SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  59.089 s
[INFO] Finished at: 2019-06-07T19:15:14+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'fabric8' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/root/.m2/repository), spring-snapshots (https://repo.spring.io/libs-snapshot-local), spring-milestones (https://repo.spring.io/libs-milestone-local), spring-releases (https://repo.spring.io/libs-release-local), central (https://repo.maven.apache.org/maven2)] -> [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

解决问题

  1. 需要修改maven的配置文件settings.xml,完整路径是apache-maven-3.6.0/conf/settings.xml
  2. 在settings.xml文件内,找到pluginGroups节点,在里面增加两行,修改完成后效果如下:
<pluginGroups>
    <pluginGroup>io.fabric8</pluginGroup>
    <pluginGroup>org.springframework.boot</pluginGroup>
  </pluginGroups>
  1. 修改完毕保存退出;

问题解决:

再次执行mvn clean package fabric8:deploy -Pkubernetes,问题解决,如下:

[INFO] --- fabric8-maven-plugin:3.5.37:deploy (default-cli) @ kubernetes-leader-election-example ---
[INFO] F8: Using Kubernetes at https://192.168.121.128:6443/ in namespace default with manifest /usr/local/work/k8s/spring-cloud-kubernetes-master/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/target/classes/META-INF/fabric8/kubernetes.yml 
[INFO] Using namespace: default
[INFO] Creating a Service from kubernetes.yml namespace default name kubernetes-leader-election-example
[INFO] Created Service: spring-cloud-kubernetes-examples/kubernetes-leader-election-example/target/fabric8/applyJson/default/service-kubernetes-leader-election-example.json
[INFO] Using namespace: default
[INFO] Creating a Deployment from kubernetes.yml namespace default name kubernetes-leader-election-example
[INFO] Created Deployment: spring-cloud-kubernetes-examples/kubernetes-leader-election-example/target/fabric8/applyJson/default/deployment-kubernetes-leader-election-example.json
[INFO] F8: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Spring Cloud Kubernetes :: Examples 1.1.0.BUILD-SNAPSHOT:
[INFO] 
[INFO] Spring Cloud Kubernetes :: Examples ................ SUCCESS [02:44 min]
[INFO] Spring Cloud Kubernetes :: Examples :: Reload ConfigMap SUCCESS [ 55.511 s]
[INFO] Spring Cloud Kubernetes :: Examples :: Hello World . SUCCESS [ 13.684 s]
[INFO] Spring Cloud Kubernetes :: Examples :: Leader Election SUCCESS [02:07 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:04 min
[INFO] Finished at: 2019-06-07T19:28:34+08:00
[INFO] ------------------------------------------------------------------------

查看kubernetes的service,发现部署成功:

[root@maven spring-cloud-kubernetes-examples]# kubectl get services
NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes                           ClusterIP   10.96.0.1       <none>        443/TCP          18h
kubernetes-hello-world               NodePort    10.100.204.21   <none>        8080:30134/TCP   5m39s
kubernetes-leader-election-example   NodePort    10.102.68.119   <none>        8080:30642/TCP   3m32s
spring-cloud-reload                  NodePort    10.98.2.101     <none>        8080:31993/TCP   5m53s

来源:https://blog.csdn.net/boling_cavalry/article/details/91132345

上一篇: Linux下minikube启动失败(It seems like the kub

下一篇: Docker多阶段构建实战(multi-stage builds)