2016-08-02 75 views
2

我一直看到Maven-dependency-plugin中標記的NoSuchElementException。我曾嘗試將aether-spi,aether-api和aether-util的依賴項添加到我的pom.xml中,但錯誤並未消失。如果我反覆更新並清理項目或運行mvn軟件包,我有時可以讓它消失。是否有可以添加的依賴項或對插件的更新,以防止出現此錯誤?我的pom.xml有什麼問題嗎?Maven-Dependency-Plugin:Aether RepositorySystem的NoSuchElementException

我使用eclipse Mars 4.5.2和Maven 3.2.3。

以下是錯誤:

java.util.NoSuchElementException 
     role: org.eclipse.aether.RepositorySystem 
    roleHint: (org.apache.maven.plugins:maven-dependency-plugin:2.10:copy-dependencies:copy-dependencies:package) 

org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException 
     role: org.eclipse.aether.RepositorySystem 
    roleHint: 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267) 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255) 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249) 
    at com.coderplus.utils.BuildHelper.<init>(BuildHelper.java:159) 
    at com.ianbrandt.tools.m2e.mdp.core.MdpBuildParticipant.build(MdpBuildParticipant.java:65) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86) 
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200) 
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245) 
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303) 
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359) 
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382) 
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144) 
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) 
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) 
Caused by: java.util.NoSuchElementException 
    at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next(RealmFilteredBeans.java:118) 
    at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next(RealmFilteredBeans.java:1) 
    at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76) 
    at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1) 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263) 
    ... 28 more 

這裏是我的插件在pom.xml中:

   <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.10</version> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${project.build.directory}/lib</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

編輯:這裏是全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/maven-v4_0_0.xsd"> 
    <parent> 
     <groupId>com.my.company</groupId> 
     <artifactId>MyApp</artifactId> 
     <version>1.0.0</version> 
     <relativePath>../pom.xml</relativePath> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.my.company.service</groupId> 
    <artifactId>MyService</artifactId> 
    <packaging>jar</packaging> 
    <name>MyService</name> 
    <build> 
     <sourceDirectory>src/main/java</sourceDirectory> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
       <version>2.6</version> 
      </plugin> 
      <plugin> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.19.1</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.5.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.10</version> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${project.build.directory}/lib</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <!-- Jetty Setup --> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.5.0</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>java</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <mainClass>com.my.company.MyApp</mainClass> 
        <classpathScope>runtime</classpathScope> 
        <webAppConfig> 
         <contextPath>/</contextPath> 
        </webAppConfig> 
        <webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory> 
        <webDefaultXml>${project.basedir}/conf/jetty/webdefault.xml</webDefaultXml> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <dependencies> 
     <!-- logging dependencies --> 
     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-classic</artifactId> 
      <version>${logback-version}</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-core</artifactId> 
      <version>${logback-version}</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
     </dependency> 

     <!-- Testing dependencies --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.easymock</groupId> 
      <artifactId>easymock</artifactId> 
      <version>3.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>4.2.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>1.7.10</version> 
     </dependency> 

     <!-- Jersey Dependencies --> 
     <dependency> 
      <groupId>org.glassfish.jersey.media</groupId> 
      <artifactId>jersey-media-multipart</artifactId> 
      <version>${jersey2-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jersey.media</groupId> 
      <artifactId>jersey-media-json-jackson</artifactId> 
      <version>${jersey2-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jersey.containers</groupId> 
      <artifactId>jersey-container-servlet</artifactId> 
      <version>${jersey2-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jersey.containers</groupId> 
      <artifactId>jersey-container-servlet-core</artifactId> 
      <version>${jersey2-version}</version> 
     </dependency> 

     <!-- Jetty Dependencies --> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-server</artifactId> 
      <version>${jetty-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-servlet</artifactId> 
      <version>${jetty-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-webapp</artifactId> 
      <version>${jetty-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-annotations</artifactId> 
      <version>${jetty-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-plus</artifactId> 
      <version>${jetty-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.ejb</groupId> 
      <artifactId>javax.ejb-api</artifactId> 
      <version>3.2</version> 
     </dependency> 

     <!-- JSON processing: jackson --> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-core</artifactId> 
      <version>${jackson-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-annotations</artifactId> 
      <version>${jackson-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
      <version>${jackson-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.datatype</groupId> 
      <artifactId>jackson-datatype-joda</artifactId> 
      <version>2.1.5</version> 
     </dependency> 
     <dependency> 
      <groupId>joda-time</groupId> 
      <artifactId>joda-time</artifactId> 
      <version>2.2</version> 
     </dependency> 

     <!-- Base64 encoding that works in both JVM and Android --> 
     <dependency> 
      <groupId>com.brsanthu</groupId> 
      <artifactId>migbase64</artifactId> 
      <version>2.2</version> 
     </dependency> 

     <!-- Spring Dependencies --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>4.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>4.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>4.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>4.2.4.RELEASE</version> 
     </dependency> 
     <!-- Aether dependencies to fix error on maven-dependency-plugin execution --> 
     <dependency> 
      <groupId>org.eclipse.aether</groupId> 
      <artifactId>aether-spi</artifactId> 
      <version>0.9.0.M2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.sonatype.aether</groupId> 
      <artifactId>aether-api</artifactId> 
      <version>1.8</version> 
     </dependency> 
     <dependency> 
      <groupId>org.sonatype.aether</groupId> 
      <artifactId>aether-util</artifactId> 
      <version>1.8</version> 
     </dependency> 
    </dependencies> 
    <properties> 
     <jersey-version>1.19.1</jersey-version> 
     <jersey2-version>2.22.1</jersey2-version> 
     <jackson-version>2.4.2</jackson-version> 
     <junit-version>4.12</junit-version> 
     <maven-plugin-version>1.0.0</maven-plugin-version> 
     <commons-lang-version>3.4</commons-lang-version> 
     <slf4j-version>1.7.21</slf4j-version> 
     <jetty-version>9.3.6.v20151106</jetty-version> 
     <coverage.complexity.minimum>0</coverage.complexity.minimum> 
     <coverage.line.minimum>0</coverage.line.minimum> 
     <coverage.missed.classes>0</coverage.missed.classes> 
    </properties> 
</project> 
+0

請張貼完整的POM文件... – khmarbaise

+0

@khmarbaise看到編輯的問題 – jencoston

+0

你喜歡製作戰爭或jar文件? – khmarbaise

回答

-2

首先你已經定義了包裝jar但你已經定義了包裝maven-war-plugin在你的pom文件中?如果您想製作戰爭檔案,請將包裝更改爲war。此外,我不知道你爲什麼使用maven-dependency-plugin將文件複製到lib文件夾?這看起來不對。此外依存關係奧德根本就是錯誤的,因爲它是使用Maven和插件,但通常不是由用戶...

+0

我添加了Aether依賴關係,試圖擺脫我看到的錯誤。你能更具體地說明我應該怎樣做才能解決這個問題嗎?我正在使用現有的pom.xml文件,所以我不確定添加插件的所有原因。我想製作一個罐子。你是否建議我刪除maven-war-plugin? – jencoston

+0

如果你創建的jar比maven-war-plugin沒有意義。此外,我不明白maven-dependency-plugin的用法:複製除去那些以太網deps .. – khmarbaise

+0

在swagger-maven-plugin網站上閱讀它。複製依賴是一個「將項目依賴關係從存儲庫複製到指定位置的目標」。所以,就我而言,我認爲它是將依賴關係複製到目標目錄。你會推薦一個不同的插件或替代方法來複制文件嗎? – jencoston