错误整理:No plugin found for prefix 'jetty' in the current project and in the plugin groups

本文介绍了在Maven项目中配置Jetty插件的方法,包括解决找不到Jetty插件的问题,以及如何通过设置`settings.xml`文件或在`pom.xml`中添加配置来启用Jetty服务器。

在maven进行jetty的调试中出现错误:

  1. [ERROR] No plugin found for prefix 'jetty' in the current project and in the plu  
  2. gin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repo  
  3. sitories [local (C:\Documents and Settings\Administrator\.m2\repository), centra  
  4. l (http://repo.maven.apache.org/maven2)] -> [Help 1]  
  5. [ERROR]  
  6. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit  
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plu
gin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repo
sitories [local (C:\Documents and Settings\Administrator\.m2\repository), centra
l (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit


详情如下:

  1. C:\myjava\workspace>mvn jetty:run  
  2. [INFO] Scanning for projects...  
  3. [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave  
  4. n-deploy-plugin:2.7: Failed to parse plugin descriptor for org.apache.maven.plug  
  5. ins:maven-deploy-plugin:2.7 (C:\Documents and Settings\Administrator\.m2\reposit  
  6. ory\org\apache\maven\plugins\maven-deploy-plugin\2.7\maven-deploy-plugin-2.7.jar  
  7. ): invalid LOC header (bad signature)  
  8. [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave  
  9. n-site-plugin:3.0: Failed to parse plugin descriptor for org.apache.maven.plugin  
  10. s:maven-site-plugin:3.0 (C:\Documents and Settings\Administrator\.m2\repository\  
  11. org\apache\maven\plugins\maven-site-plugin\3.0\maven-site-plugin-3.0.jar): inval  
  12. id LOC header (bad signature)  
  13. Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-  
  14. metadata.xml  
  15. Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadat  
  16. a.xml  
  17. Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-m  
  18. etadata.xml (11 KB at 10.7 KB/sec)  
  19. Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata  
  20. .xml (22 KB at 18.2 KB/sec)  
  21. [INFO] ------------------------------------------------------------------------  
  22. [INFO] BUILD FAILURE  
  23. [INFO] ------------------------------------------------------------------------  
  24. [INFO] Total time: 2.110s  
  25. [INFO] Finished at: Sun Mar 03 17:31:20 CST 2013  
  26. [INFO] Final Memory: 4M/15M  
  27. [INFO] ------------------------------------------------------------------------  
  28. [ERROR] No plugin found for prefix 'jetty' in the current project and in the plu  
  29. gin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repo  
  30. sitories [local (C:\Documents and Settings\Administrator\.m2\repository), centra  
  31. l (http://repo.maven.apache.org/maven2)] -> [Help 1]  
  32. [ERROR]  
  33. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit  
C:\myjava\workspace>mvn jetty:run
[INFO] Scanning for projects...
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-deploy-plugin:2.7: Failed to parse plugin descriptor for org.apache.maven.plug
ins:maven-deploy-plugin:2.7 (C:\Documents and Settings\Administrator\.m2\reposit
ory\org\apache\maven\plugins\maven-deploy-plugin\2.7\maven-deploy-plugin-2.7.jar
): invalid LOC header (bad signature)
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-site-plugin:3.0: Failed to parse plugin descriptor for org.apache.maven.plugin
s:maven-site-plugin:3.0 (C:\Documents and Settings\Administrator\.m2\repository\
org\apache\maven\plugins\maven-site-plugin\3.0\maven-site-plugin-3.0.jar): inval
id LOC header (bad signature)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadat
a.xml
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-m
etadata.xml (11 KB at 10.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata
.xml (22 KB at 18.2 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.110s
[INFO] Finished at: Sun Mar 03 17:31:20 CST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plu
gin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repo
sitories [local (C:\Documents and Settings\Administrator\.m2\repository), centra
l (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit



settings.xml没有配置插件应此需要
  1. mvn org.mortbay.jetty:maven-jetty-plugin:run   
mvn org.mortbay.jetty:maven-jetty-plugin:run 

这样来运行。
如果需要使用jetty:run,那么必须在maven的setting.xml下配置
  1. <pluginGroups>  
  2.     <pluginGroup>org.mortbay.jetty</pluginGroup>  
  3.   </pluginGroups>  
<pluginGroups>
    <pluginGroup>org.mortbay.jetty</pluginGroup>
  </pluginGroups>

或者在对应项目的pom.xml中plugins的节点下添加配置

  1. <plugin>  
  2.                 <groupId>org.mortbay.jetty</groupId>  
  3.                 <artifactId>jetty-maven-plugin</artifactId>  
  4.                 <configuration>  
  5.                     <webApp>  
  6.                         <contextPath>/</contextPath>  
  7.                     </webApp>  
  8.                     <stopKey>webx</stopKey>  
  9.                     <stopPort>9999</stopPort>  
  10.                     <connectors>  
  11.                         <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">  
  12.                             <port>8081</port>  
  13.                             <maxIdleTime>60000</maxIdleTime>  
  14.                         </connector>  
  15.                     </connectors>  
  16.                     <requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">  
  17.                         <filename>target/access.log</filename>  
  18.                         <retainDays>90</retainDays>  
  19.                         <append>false</append>  
  20.                         <extended>false</extended>  
  21.                         <logTimeZone>GMT+8:00</logTimeZone>  
  22.                     </requestLog>  
  23.                     <systemProperties>  
  24.                         <systemProperty>  
  25.                             <name>productionMode</name>  
  26.                             <value>${productionMode}</value>  
  27.                         </systemProperty>  
  28.                     </systemProperties>  
  29.                 </configuration>  
  30.             </plugin>  
<plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                    <stopKey>webx</stopKey>
                    <stopPort>9999</stopPort>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>8081</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <requestLog implementation="org.eclipse.jetty.server.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>${productionMode}</value>
                        </systemProperty>
                    </systemProperties>
                </configuration>
            </plugin>

Maven 中出现 `No plugin found for prefix 'dependency'` 错误的原因是当前项目未正确配置或未识别到 `maven-dependency-plugin` 插件,导致无法通过简写命令(如 `mvn dependency:tree` 或 `mvn dependency:copy-dependencies`)执行相关操作。 要解决这个问题,可以通过以下几种方式: ### 1. 显式指定插件全称和版本 在命令行中直接使用完整的插件名称和版本信息,避免使用前缀解析机制。例如: ```bash mvn org.apache.maven.plugins:maven-dependency-plugin:3.5.0:tree ``` 该方式适用于临时查看依赖树或复制依赖项的场景,无需修改 `pom.xml` 文件[^3]。 ### 2. 在 `pom.xml` 中添加 `maven-dependency-plugin` 配置 为确保能够使用简写命令(如 `mvn dependency:tree`),建议在项目的 `pom.xml` 文件中的 `<build>` 部分添加如下插件配置: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.5.0</version> <executions> <execution> <id>dependency-tree</id> <phase>compile</phase> <goals> <goal>tree</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ``` 此配置将插件绑定到 `compile` 生命周期阶段,并启用 `tree` 目标以支持 `mvn dependency:tree` 命令[^4]。 ### 3. 检查 Maven 的全局配置与网络环境 如果问题仍然存在,可能是由于本地仓库未正确下载插件 JAR 文件所致。可以尝试以下操作: - 清理本地 Maven 仓库缓存,删除对应插件目录后重新构建: ```bash mvn dependency:purge-local-repository ``` - 确保网络连接正常,Maven 能够访问远程仓库并下载所需插件文件。 ### 4. 使用 Spring Boot 项目时的额外注意事项 若项目基于 Spring Boot 构建,还需确认是否已正确引入 `spring-boot-maven-plugin` 并保持其与 `maven-dependency-plugin` 的兼容性: ```xml <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> ``` 确保两个插件之间没有版本冲突或生命周期覆盖的问题[^4]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值