Java 未找到前缀为';执行官';在当前项目和插件组org.codehaus.mojo中

Java 未找到前缀为';执行官';在当前项目和插件组org.codehaus.mojo中,java,spring,maven,maven-3,exec-maven-plugin,Java,Spring,Maven,Maven 3,Exec Maven Plugin,我已经阅读了几个问题与类似的问题和帮助1页。不幸的是,我被卡住了 一个可能的原因可能是代理造成的,但这里没有这样的代理。此外,当我从Eclipse更新它时,我PC中的所有maven项目都已成功更新。所以我放弃了这种可能性 我检查的另一件事是在本地存储库中查找codehaus,我找到了它(C:\Users\myUser.m2\repository\org\codehaus\mojo) 另一次尝试,我尝试在设置中添加pluginGroup/pluginGroup。 该项目是一个非常简单的hello

我已经阅读了几个问题与类似的问题和帮助1页。不幸的是,我被卡住了

一个可能的原因可能是代理造成的,但这里没有这样的代理。此外,当我从Eclipse更新它时,我PC中的所有maven项目都已成功更新。所以我放弃了这种可能性

我检查的另一件事是在本地存储库中查找codehaus,我找到了它(C:\Users\myUser.m2\repository\org\codehaus\mojo)

另一次尝试,我尝试在设置中添加pluginGroup/pluginGroup。 该项目是一个非常简单的hello word,使用spring批处理,只有一个Tasklet及其执行方法。没有公共静态void main方法

Command.exe,在添加Matteo建议后打印整个错误:

C:\temp\TaskletJavaConfig\spring-batch-helloworld>mvn compile exec:java -e
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-p
lugin/1.1/exec-maven-plugin-1.1.pom
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:exec-maven-
plugin:1.1: Plugin org.codehaus.mojo:exec-maven-plugin:1.1 or one of its depende
ncies could not be resolved: Failed to read artifact descriptor for org.codehaus
.mojo:exec-maven-plugin:jar:1.1
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or
one of its dependencies could not be resolved: Failed to read artifact descripto
r for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one
of its dependencies could not be resolved: Failed to read artifact descriptor fo
r org.apache.maven.plugins:maven-site-plugin:jar:3.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or
one of its dependencies could not be resolved: Failed to read artifact descripto
r for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plu
gin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read
artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-b
eta-5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin
:2.8 or one of its dependencies could not be resolved: Failed to read artifact d
escriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-release-plugin:2.3
.2 or one of its dependencies could not be resolved: Failed to read artifact des
criptor for org.apache.maven.plugins:maven-release-plugin:jar:2.3.2
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metada
ta.xml
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-metadata.xml
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/
to central (https://repo.maven.apache.org/maven2): sun.security.validator.Valida
torException: PKIX path building failed: sun.security.provider.certpath.SunCertP
athBuilderException: unable to find valid certification path to requested target

[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xm
l from/to central (https://repo.maven.apache.org/maven2): sun.security.validator
.ValidatorException: PKIX path building failed: sun.security.provider.certpath.S
unCertPathBuilderException: unable to find valid certification path to requested
target
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from https://
repo.maven.apache.org/maven2 was cached in the local repository, resolution will
not be reattempted until the update interval of central has elapsed or updates
are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-
metadata.xml from/to central (https://repo.maven.apache.org/maven2): sun.securit
y.validator.ValidatorException: PKIX path building failed: sun.security.provider
.certpath.SunCertPathBuilderException: unable to find valid certification path t
o requested target
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from h
ttps://repo.maven.apache.org/maven2 was cached in the local repository, resoluti
on will not be reattempted until the update interval of central has elapsed or u
pdates are forced. Original error: Could not transfer metadata org.apache.maven.
plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2
): sun.security.validator.ValidatorException: PKIX path building failed: sun.sec
urity.provider.certpath.SunCertPathBuilderException: unable to find valid certif
ication path to requested target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.094 s
[INFO] Finished at: 2016-01-13T12:48:00-06:00
[INFO] Final Memory: 13M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'exec' in the current project and in the plug
in groups [org.codehaus.mojo, org.apache.maven.plugins] available from the repos
itories [local (C:\Users\myUser\.m2\repository), central (https://repo.maven.ap
ache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found
for prefix 'exec' in the current project and in the plugin groups [org.codehaus.
mojo, org.apache.maven.plugins] available from the repositories [local (C:\Users
\myUser\.m2\repository), central (https://repo.maven.apache.org/maven2)]
        at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.r
esolve(DefaultPluginPrefixResolver.java:93)
        at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginF
orPrefix(MojoDescriptorCreator.java:265)
        at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDesc
riptor(MojoDescriptorCreator.java:219)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalcul
ator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:103)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalcul
ator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83)
       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:89)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
[ERROR]
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF
orPrefixException

C:\temp\TaskletJavaConfig\spring-batch-helloworld>
没有代理的证据

C:\temp\TaskletJavaConfig\spring-batch-helloworld>netsh winhttp show proxy

Current WinHTTP proxy settings:

    Direct access (no proxy server).
pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.test</groupId>
       <artifactId>spring-batch-helloworld</artifactId>
       <version>20131227</version>
       <name>spring batch hello world</name>
       <packaging>jar</packaging>

       <!-- pluginRepositories>
              <pluginRepository>
                     <id>numberformat-releases</id>
                     <url>https://raw.github.com/numberformat/20130213/master/repo</url>
              </pluginRepository>
       </pluginRepositories-->

       <properties>
              <spring.framework.version>3.2.1.RELEASE</spring.framework.version>
              <spring.batch.version>3.0.0.M2</spring.batch.version>
       </properties>

       <repositories>
              <repository>
                     <id>spring-s3</id>
                     <name>Spring Maven MILESTONE Repository</name>
                     <url>http://maven.springframework.org/milestone</url>
              </repository>
       </repositories>
       <dependencies>
              <dependency>
                     <groupId>commons-lang</groupId>
                     <artifactId>commons-lang</artifactId>
                     <version>2.6</version>
              </dependency>
              <dependency>
                     <groupId>org.springframework.batch</groupId>
                     <artifactId>spring-batch-core</artifactId>
                     <version>${spring.batch.version}</version>
              </dependency>
              <dependency>
                     <groupId>org.springframework.batch</groupId>
                     <artifactId>spring-batch-infrastructure</artifactId>
                     <version>${spring.batch.version}</version>
              </dependency>
              <dependency>
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
                     <version>1.2.17</version>
              </dependency>
              <dependency>
                     <groupId>junit</groupId>
                     <artifactId>junit</artifactId>
                     <version>4.8.2</version>
                     <scope>test</scope>
              </dependency>
              <dependency>
                     <groupId>org.springframework</groupId>
                     <artifactId>spring-tx</artifactId>
                     <version>${spring.framework.version}</version>
              </dependency>
              <dependency>
                     <groupId>org.springframework</groupId>
                     <artifactId>spring-jdbc</artifactId>
                     <version>${spring.framework.version}</version>
              </dependency>
              <dependency>
                     <groupId>hsqldb</groupId>
                     <artifactId>hsqldb</artifactId>
                     <version>1.8.0.7</version>
              </dependency>
       </dependencies>
<!-- added after Matteo recommendation-->
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
            <configuration>
 <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
            <arguments>
                <argument>com.test.config.HelloWorldJobConfig</argument>
                <argument>helloWorldJob</argument>
            </arguments>
            </configuration>
        </plugin>
</plugins>
</build>
       <!-- build>
              <plugins>
                     <plugin>
                           <groupId>github.numberformat</groupId>
                           <artifactId>blog-plugin</artifactId>
                           <version>1.0-SNAPSHOT</version>
                           <configuration>
                                  <gitUrl>https://github.com/numberformat/wordpress/tree/master/${project.version}/${project.artifactId}</gitUrl>
                           </configuration>
                           <executions>
                                  <execution>
                                         <id>1</id>
                                         <phase>site</phase>
                                         <goals>
                                                <goal>generate</goal>
                                         </goals>
                                  </execution>
                           </executions>
                     </plugin>
              </plugins>
       </build-->

<!-- Run the application using:
mvn compile exec:java -Dexec.mainClass=org.springframework.batch.core.launch.support.CommandLineJobRunner -Dexec.args="com.test.config.HelloWorldJobConfig helloWorldJob"
-->
</project>

您应该将pom文件配置为至少声明以下内容:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>
    </plugins>
</build>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
        <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
        <arguments>
            <argument>com.test.config.HelloWorldJobConfig</argument>
            <argument>helloWorldJob</argument>
        </arguments>
    </configuration>
</plugin>
mvn compile mvn org.codehaus.mojo:exec-maven-plugin:1.1:java
通过在POM中将它们配置为相同插件配置的一部分,如下所示:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>
    </plugins>
</build>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
        <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
        <arguments>
            <argument>com.test.config.HelloWorldJobConfig</argument>
            <argument>helloWorldJob</argument>
        </arguments>
    </configuration>
</plugin>
mvn compile mvn org.codehaus.mojo:exec-maven-plugin:1.1:java
它应该执行相同的预期结果


更新1
事实上,您的maven执行在访问网络上的插件元数据时遇到了问题:

[警告]检索org.codehaus.mojo:exec maven的插件描述符失败- plugin:1.1:plugin org.codehaus.mojo:exec maven plugin:1.1或其依赖项之一无法解析:无法读取org.codehaus的工件描述符 .mojo:execmaven插件:jar:1.1


更新2
如果插件前缀一直存在问题,那么这可能取决于您的网络设置。可以通过调用Exec Maven插件来执行快速检查,该插件不是通过其插件前缀(
Exec
),而是通过完整的限定名,如下所示:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>
    </plugins>
</build>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
        <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
        <arguments>
            <argument>com.test.config.HelloWorldJobConfig</argument>
            <argument>helloWorldJob</argument>
        </arguments>
    </configuration>
</plugin>
mvn compile mvn org.codehaus.mojo:exec-maven-plugin:1.1:java
注意模式:我们正在调用maven,然后是一个groupId:artifactId:version:goal,它将完全相同。这将检查您的pom配置(和插件配置)是否正确


更新3
如您的输出日志所示,Maven正试图通过https
https
(注意最后的“s”)访问存储库,因此通过SSL访问存储库,然后在生成输出中出现证书问题:

太阳 .security.validator.validator异常:PKIX路径生成失败:sun.security。 provider.certpath.SunCertPathBuilderException:找不到有效的certificatio n到请求目标的路径

那么你有两个选择:

  • 告诉maven忽略SSL错误,如另一篇文章中所述
  • 首先通过运行
    mvn help:effective settings
    检查您的设置,以确保您获得了maven应用的真实设置(如果该命令可以实际工作),然后在设置中使用另一个选项重新配置非SSL存储库

Matteo,谢谢你的回答,但不幸的是,我仍然面临同样的问题。我在上面的POM中更新了您的建议,并使用-e开关运行错误消息,以便您可以在日志中查看更多详细信息。您是否可以尝试代替mvn exec:java来执行:mvn org.codehaus.mojo:exec maven plugin:1.1:java?这应该在不使用插件前缀的情况下执行目标,只是为了检查它是否会成功。我相应地更新了我的答案(在它的底部),以使它更清楚。马特奥,你是对的。只有科德豪斯失败了。我觉得奇怪的是,我的机器中没有代理设置,我可以从任何浏览器打开maven站点。另外,我尝试直接从Eclipse(Sprint工具套件)运行,并且运行正常。有什么问题吗?好的,我知道了,如果你看一下你的错误日志,maven试图从https(注意最后的“s”)下载人工制品和插件描述符,因此通过SSL,然后它遇到了一个关于证书的问题。所以有两种可能的解决方案:要么告诉maven忽略证书错误,要么配置一个非https存储库,我将相应地用更多的详细信息更新我的答案。你的第一个答案对我不起作用。在你的第二个答案中,有两种选择。第一个(安全配置文件)完全解决了我的问题。第二个(插件库)也存在同样的问题。另外,为了帮助未来的读者,在我修复了我的问题后,触发了另一个与spring相关的问题,我通过将java、spring和spring批处理更改为最新的批处理来修复它。如果打开
https://repo.maven.apache.org/maven2
,会发生什么?似乎您的maven无法访问远程存储库,可能使用了损坏的本地存储库JAR。。。尝试从本地存储库中删除(.m2/org/codehaus/mojo/exec maven plugin/1.1/)您可以使用mvn帮助:有效设置的输出更新您的设置吗?