2016-01-13 57 views
2

我已閱讀了幾個類似問題和幫助1頁面的問題。不幸的是,我被卡住了。沒有在當前項目和插件組中找到前綴'exec'的插件org.codehaus.mojo

一個可能的原因可能是由代理引起的,但這裏沒有這樣的代理。此外,當我從Eclipse更新它時,我的PC中的所有Maven項目都已成功更新。所以我放棄了這種可能性。

我檢查的其他事情是在我的本地存儲庫中查找codehaus,並找到它(C:\ Users \ myUser.m2 \ repository \ org \ codehaus \ mojo)。

另一個嘗試,我試着在設置中添加pluginGroups/pluginGroup。 該項目是一個非常簡單的問候單詞,只使用一個Tasklet及其執行方法使用Spring批處理。沒有公共的靜態void main方法。

COMMAND.EXE與後我添加利瑪建議印刷整個錯誤:

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> 

設置.xml

<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 

    <pluginGroups> 
       <pluginGroup>org.codehaus.mojo</pluginGroup> 
    </pluginGroups> 

    <proxies> 
    </proxies> 
    <servers> 
    </servers> 
    <mirrors> 
    </mirrors> 
    <profiles> 
    </profiles> 
</settings> 

日誌只有MVN org.codehaus.mojo

C:\temp\TaskletJavaConfig\spring-batch-helloworld>mvn org.codehaus.mojo:exec-mav 
en-plugin:1.1:java 
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] 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 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.356 s 
[INFO] Finished at: 2016-01-13T15:29:20-06:00 
[INFO] Final Memory: 10M/123M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Plugin org.codehaus.mojo:exec-maven-plugin:1.1 or one of its dependencie 
s could not be resolved: Failed to read artifact descriptor for org.codehaus.moj 
o:exec-maven-plugin:jar:1.1: Could not transfer artifact org.codehaus.mojo:exec- 
maven-plugin:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): sun 
.security.validator.ValidatorException: PKIX path building failed: sun.security. 
provider.certpath.SunCertPathBuilderException: unable to find valid certificatio 
n path to requested target -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit 
ch. 
[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/PluginResoluti 
onException 

C:\temp\TaskletJavaConfig\spring-batch-helloworld>mvn compile mvn org.codehaus.m 
ojo:exec-maven-plugin:1.1:java 
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] 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 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.250 s 
[INFO] Finished at: 2016-01-13T15:31:03-06:00 
[INFO] Final Memory: 11M/123M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Plugin org.codehaus.mojo:exec-maven-plugin:1.1 or one of its dependencie 
s could not be resolved: Failed to read artifact descriptor for org.codehaus.moj 
o:exec-maven-plugin:jar:1.1: Could not transfer artifact org.codehaus.mojo:exec- 
maven-plugin:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): sun 
.security.validator.ValidatorException: PKIX path building failed: sun.security. 
provider.certpath.SunCertPathBuilderException: unable to find valid certificatio 
n path to requested target -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit 
ch. 
[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/PluginResoluti 
onException 
+0

如果您打開「https:// repo.maven.apache.org/maven2」,會發生什麼情況?似乎你maven不能訪問遠程存儲庫,也許使用損壞的本地存儲庫jar ...試圖從你的本地存儲庫中刪除(.m2/org/codehaus/mojo/exec-maven-plugin/1.1 /) – Valijon

+0

你能否更新你的設置輸出mvn help:有效設置? –

回答

2

您應該配置您的POM文件至少聲明Exec Maven Plugin如下:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.1</version> 
     </plugin> 
    </plugins> 
</build> 

這樣,你就可以使用exec:java plugin:goal命令。


你甚至可以避開選擇:

-Dexec.mainClass=org.springframework.batch.core.launch.support.CommandLineJobRunner -Dexec.args="com.test.config.HelloWorldJobConfig helloWorldJob" 

通過在你的POM中配置它們作爲同一插件配置的一部分如下:

<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 exec:java 

它應該執行相同的預期結果。


UPDATE1
事實上,你的Maven執行遇到問題時嘗試訪問網絡上的插件元數據:

[警告]無法檢索插件描述符org.codehaus.mojo: exec-maven- 插件:1.1:插件org.codehaus.mojo:exec-maven-plugin:1。1或它的一個依賴無法解析:無法讀取工件描述符org.codehaus .mojo:EXEC-Maven的插件:罐子:1.1


UPDATE2
如果你保持在插件前綴有問題時,確實可能取決於您的網絡設置。

mvn compile mvn org.codehaus.mojo:exec-maven-plugin:1.1:java 

注模式:快速檢查可以通過通過不是它的插件前綴(exec),但通過全限定名調用Exec的Maven插件如下進行,我們正在調用的Maven,那麼的groupId:artifactId的:版本:目標,它將完全相同。這將檢查你的pom配置(和插件配置)是否正確。


UPDATE3
作爲你的輸出日誌看出,Maven是試圖通過https訪問存儲庫(注意最後的「S」),通過SSL因此,然後有與證書問題作爲構建的一部分輸出:

sun .security.validator.ValidatorException:PKIX路徑構建失敗:sun.security。 provider.certpath.SunCertPathBuilderException:無法找到請求的目標有效的專業認證 N通路

你有那麼兩個選項:

  • 泰爾行家忽略SSL錯誤,在另一個SO answer
  • 描述
  • 首先通過運行mvn help:effective-settings來檢查您的設置,以確保獲得maven應用的真實設置(如果該命令實際可用),然後在您的設置中重新配置非SSL存儲庫,並使用另一個替代SO answer
+0

Matteo,謝謝你的回答,但不幸的是我仍然面臨同樣的問題。我使用POM中的建議更新了上面的內容,錯誤消息使用-e開關運行,因此您可以在日誌中看到更多詳細信息。 –

+1

你可以嘗試而不是mvn exec:java來執行:mvn org.codehaus.mojo:exec-maven-plugin:1.1:java?這應該執行目標而不使用插件前綴,只是爲了檢查它是否會工作。我相應地更新了我的答案(在其底部),以便說清楚。 –

+0

馬泰奧,你是對的。它只有通過codehaus纔會失敗。我發現奇怪的是,我沒有在我的機器上設置代理服務器,我可以從任何瀏覽器打開Maven站點。另外,我嘗試從Eclipse(Sprint Tool Suite)直接運行,並且運行正確。什麼可能是錯的? –

相關問題