解决webx项目启动时提示 No plugin found for prefix 'jetty' in the current project and in the plugin group错误

1、建立webx项目

按照网上的教程建立webx项目时,采用的命令以下:web

mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=tutorial1 -Dversion=1.0-SNAPSHOT -Dpackage=com.alibaba.webx.tutorial1 -DarchetypeArtifactId=archetype-webx-quickstart -DarchetypeGroupId=com.alibaba.citrus.sample -DarchetypeVersion=1.0 -DinteractiveMode=false

运行mvn jetty:run时,出现的错误为:apache

No plugin found for prefix 'jetty' in the current project and in the plugin groups [com.alibaba.org.apache.maven.plugins, com.alibaba.maven.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositorie
s [local (d:\mvn\repo), tbmirror-all (http://mvnrepo.alibaba-inc.com/mvn/repository)] -> [Help 1]

2、问题排查

方法一:直接查看pom.xml中,发现没有dependency的依赖,添加 以后,运行显示:app

<groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <configuration>
          <contextPath>/</contextPath>
          <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
              <port>8081</port>
              <maxIdleTime>60000</maxIdleTime>
            </connector>
          </connectors>
          <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
            <filename>target/access.log</filename>
            <retainDays>90</retainDays>
            <append>false</append>
            <extended>false</extended>
            <logTimeZone>GMT+8:00</logTimeZone>
          </requestLog>
          <systemProperties>
            <systemProperty>
              <name>productionMode</name>
              <value>false</value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>

运行显示:webapp

Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:7.0.0.pre5:run (default-cli) on project tutorial1: Webapp source directory D:\Code\tutorial1\src\main\webapp does no
t exist

8081端口也没有监听。maven

方法二:看别人搭建过程和个人同样,然而pom.xml自动生成了,而且有jetty依赖,且自动生成了webapp文件夹。认真对比了命令行,发现是archetype的版本号太旧了,-DarchetypeVersion=1.8,更改以后,运行正常。svg

3、思考

一个bug纠结了1个小时,最后发现是参考手册比较旧了,版本号有问题。参照建立项目时,又出现了文件结构不一致的问题,下次有时间将这个参考手册更新一下啊~ui

总结:插件

mvn archetype:generate        使用archetype插件自动生成 
-DgroupId=com.alibaba.webx   groupId和artifactId肯定惟一的maven坐标
-DartifactId=tutorial1         
-Dversion=1.0-SNAPSHOT 
-Dpackage=com.alibaba.webx.tutorial1    
-DarchetypeArtifactId=archetype-webx-quickstart       archetype模板,建立webapp和自动生成pom.xml
-DarchetypeGroupId=com.alibaba.citrus.sample 
-DarchetypeVersion=1.8
-DinteractiveMode=false