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

在创建webx项目并尝试使用mvn jetty:run命令时遇到No plugin found for prefix 'jetty'错误。通过检查pom.xml发现缺少jetty依赖,添加后仍无法正常启动。进一步排查发现是archetype版本过旧,更新到1.8以上版本后问题解决,项目成功启动。此问题提醒我们在参考教程时应注意版本匹配,避免因版本差异导致的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、创建webx项目

按照网上的教程创建webx项目时,采用的命令如下:

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时,出现的错误为:

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]

二、问题排查

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

<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>

运行显示:

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端口也没有监听。

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

三、思考

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

总结:

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          
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值