为什么maven找不到插件?

发布于 2024-07-09 03:17:53 字数 613 浏览 5 评论 0原文

如果我输入命令:

mvn dependency:list

docs 建议我会得到一个我的项目的依赖项列表。 相反,我得到的是这样的:

[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] -----------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] -----------------------------------------------------------
[INFO] Required goal not found: dependency:list

称我为充满希望的天真,但我希望 Maven 能够下载它没有的任何插件。 有谁知道什么可能导致此错误? 有谁知道maven在哪里存储有关它安装的插件的信息,以及它们在maven存储库中的存储位置?

If I type the command:

mvn dependency:list

The docs suggest that I'll get a list of my project's dependencies. Instead though, I get this:

[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] -----------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] -----------------------------------------------------------
[INFO] Required goal not found: dependency:list

Call me a hopeful naive, but I had hoped maven would download any plugins it didn't have. Does anyone know what might be leading to this error? Does anyone know where maven stores information about what plugins it has installed, and where they're stored in the maven repository?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

橘味果▽酱 2024-07-16 03:17:53

您是否尝试过mvn -cpu dependency:list(或:mvn --check-plugin-updates dependency:list)? 可能您的依赖插件版本较旧,没有目标 list

如果这没有帮助,请尝试升级 Maven。 由于 Super POM 为大多数重要插件(包括依赖插件)提供了 2.0.9 默认版本,因此将下载 2.0 版本(其具有 list 目标)。

或者您可以尝试从存储库中删除插件的缓存版本 (~/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/,其中 ~ 是用户主目录)。

Have you tried mvn -cpu dependency:list (or: mvn --check-plugin-updates dependency:list)? Probably, you have older version of dependency plugin which does not have goal list

If this does not help, try upgrading Maven. Since 2.0.9 default versions are provided by the Super POM for most important plugins (dependency plug-in included), so 2.0 version will be downloaded (which has list goal).

Or you can try removing the cached version of the plug-in from the repository (~/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/, where ~ is the user home directory).

善良天后 2024-07-16 03:17:53

我在公司防火墙后面也得到了类似的结果。 配置 (settings.xml) 中的代理设置可能就是答案。

<proxies>
  <proxy>
   <id>proxy</id> 
   <active>true</active> 
   <username>user</username>
   <password>passwrd</password>
   <protocol>http</protocol>
   <host>example.proxy.name.com</host>
  <port>80</port>
 </proxy>
</proxies>

I have gotten a similiar result from being behind the corporate firewall. Proxy settings in your config (settings.xml) might be the answer.

<proxies>
  <proxy>
   <id>proxy</id> 
   <active>true</active> 
   <username>user</username>
   <password>passwrd</password>
   <protocol>http</protocol>
   <host>example.proxy.name.com</host>
  <port>80</port>
 </proxy>
</proxies>
苏辞 2024-07-16 03:17:53

为了回答我自己的问题,感谢对其进行的一些评论,settings.xml 文件已被自定义,并且没有列出中央 Maven 存储库。

哎呀。

To answer my own question, thanks to some comments that were made on it, the settings.xml file had been customized and did not list the central maven repository.

Oops.

尹雨沫 2024-07-16 03:17:53

通过在论坛(回答上面发布的许多后续问题)或邮件列表时了解失败尝试的所有详细信息,可以更轻松地解决许多 Maven 问题,这是通过使用调试和异常选项运行 Maven 来完成的像这样切换:mvn; -X -e

示例输出将如下所示:

[~/Documents/Temp/Scratch] mvn clean -e -X
Using Java version: 1.6
+ Error stacktraces are turned on.
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.6" arch: "x86_64" Family: "mac"
[DEBUG] Building Maven user-level plugin registry from: '/Users/mccm06/.m2/plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: '/Applications/Dev/apache-maven/conf/plugin-registry.xml'
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::10 for project: null:maven-clean-plugin:maven-plugin:2.2 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::7 for project: org.apache.maven.plugins:maven-plugins:pom:10 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache::4 for project: org.apache.maven:maven-parent:pom:7 from the repository.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:377)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        ... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Feb 16 10:59:39 MST 2009
[INFO] Final Memory: 2M/7M
[INFO] ------------------------------------------------------------------------

Many Maven troubles can be solved easier by knowing all the details of the failed attempt when posting to forums (answering many of the follow-up questions folks above posted) or mailing list, and this is accomplished by running Maven with the debug and exception option switches like so: mvn <yourgoal> -X -e

Sample output then will look like this:

[~/Documents/Temp/Scratch] mvn clean -e -X
Using Java version: 1.6
+ Error stacktraces are turned on.
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.6" arch: "x86_64" Family: "mac"
[DEBUG] Building Maven user-level plugin registry from: '/Users/mccm06/.m2/plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: '/Applications/Dev/apache-maven/conf/plugin-registry.xml'
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::10 for project: null:maven-clean-plugin:maven-plugin:2.2 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::7 for project: org.apache.maven.plugins:maven-plugins:pom:10 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache::4 for project: org.apache.maven:maven-parent:pom:7 from the repository.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:377)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        ... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Feb 16 10:59:39 MST 2009
[INFO] Final Memory: 2M/7M
[INFO] ------------------------------------------------------------------------
尤怨 2024-07-16 03:17:53

尝试最新的maven版本,通常升级到新版本可以解决问题。

Try latest maven version, usually upgrades to newer versions solve issues.

伴我心暖 2024-07-16 03:17:53

虽然与修复的问题无关,但首先您应该执行 install,然后才尝试执行插件的目标。

While unrelated to your issue being fixed, first you should execute install and only then try executing goals for your plugin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文