Maven构建错误:无法设置org.apache.maven.shared.filtering.MavenResourcesFiltering字段

时间:2014-05-25 13:31:45

标签: java eclipse maven

我正在尝试创建一个具有spring和hibernate的某些依赖项的maven项目。我的pom.xml很好,没有错误,maven install可以正常运行BUILD SUCCESS消息。但是,当我尝试运行我的项目: - 运行as-> Maven build->干净的包,它抛出一个异常,即:

   com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting: protected org.apache.maven.shared.filtering.MavenResourcesFiltering org.apache.maven.plugin.resources.ResourcesMojo.mavenResourcesFiltering
  while locating org.apache.maven.plugin.resources.ResourcesMojo

1 error
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1006)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
    at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:133)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:260)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:252)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:459)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    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.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: java.lang.IllegalArgumentException: Can not set org.apache.maven.shared.filtering.MavenResourcesFiltering field org.apache.maven.plugin.resources.ResourcesMojo.mavenResourcesFiltering to org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
    at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
    at java.lang.reflect.Field.set(Field.java:657)
    at org.eclipse.sisu.bean.BeanPropertyField.set(BeanPropertyField.java:72)
    at org.eclipse.sisu.plexus.ProvidedPropertyBinding.injectProperty(ProvidedPropertyBinding.java:48)
    at org.eclipse.sisu.bean.BeanInjector.injectMembers(BeanInjector.java:52)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:128)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:118)
    at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
    at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:92)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:116)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:269)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1054)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
    ... 42 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.502s
[INFO] Finished at: Sun May 25 18:45:01 IST 2014
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project Example: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Unable to load the mojo 'resources' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-resources-plugin:2.6': com.google.inject.ProvisionException: Guice provision errors:
[ERROR] 
[ERROR] 1) Error injecting: protected org.apache.maven.shared.filtering.MavenResourcesFiltering org.apache.maven.plugin.resources.ResourcesMojo.mavenResourcesFiltering
[ERROR] while locating org.apache.maven.plugin.resources.ResourcesMojo
[ERROR] at ClassRealm[plugin>org.apache.maven.plugins:maven-resources-plugin:2.6, parent: sun.misc.Launcher$AppClassLoader@35ce36]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-resources-plugin:2.6:resources)
[ERROR] 
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: org.apache.maven.plugins:maven-resources-plugin:2.6:resources: Can not set org.apache.maven.shared.filtering.MavenResourcesFiltering field org.apache.maven.plugin.resources.ResourcesMojo.mavenResourcesFiltering to org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering

我的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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>Example</groupId>
  <artifactId>Example</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Example</name>
  <url>http://maven.apache.org</url>



  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>2.10.1</version>
        </dependency> 
            <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
         <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>2.2.12</version>

        </dependency> 

            <!-- Spring framework -->
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>2.5.6</version>
      </dependency> 
      <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
        <version>1.0.3.RELEASE</version>
    </dependency> 
     <dependency>  
       <groupId>org.springframework</groupId>  
       <artifactId>spring-core</artifactId>  
       <version>${org.springframework.version}</version>  
     </dependency>  
     <dependency>  
       <groupId>org.springframework</groupId>  
       <artifactId>spring-context</artifactId>  
       <version>${org.springframework.version}</version>  
     </dependency>  
     <dependency>  
       <groupId>org.springframework</groupId>  
       <artifactId>spring-aop</artifactId>  
       <version>${org.springframework.version}</version>  
     </dependency>  

     <dependency>  
       <groupId>org.springframework</groupId>  
       <artifactId>spring-context-support</artifactId>  
       <version>${org.springframework.version}</version>  
     </dependency> 
     <dependency>  
       <groupId>org.springframework</groupId>  
       <artifactId>spring-tx</artifactId>  
       <version>${org.springframework.version}</version>  
     </dependency>  


     <!-- Hibernate framework -->  
     <dependency>  
       <groupId>org.hibernate</groupId>  
       <artifactId>hibernate-core</artifactId>  
       <version>${org.hibernate.version}</version>  
     </dependency>  
     <dependency>  
       <groupId>org.hibernate</groupId>  
       <artifactId>hibernate-entitymanager</artifactId>  
       <version>${org.hibernate.version}</version>  
     </dependency> 
     <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>ejb3-persistence</artifactId>
        <version>1.0.1.GA</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-annotations</artifactId>
      <version>3.3.1.GA</version>
    </dependency> 
     <!-- Hibernate library dependecy start -->  
     <dependency>  
       <groupId>dom4j</groupId>  
       <artifactId>dom4j</artifactId>  
       <version>1.6.1</version>  
     </dependency>  

     <dependency>  
       <groupId>antlr</groupId>  
       <artifactId>antlr</artifactId>  
       <version>2.7.7</version>  
     </dependency>  
     <!-- Hibernate library dependency end -->  


  </dependencies>

  <properties>  

     <org.aspectj.version>1.6.11</org.aspectj.version>  
     <!--cxf.version>2.2.12</cxf.version-->  
     <org.hibernate.version>3.6.7.Final</org.hibernate.version>  
     <org.springframework.version>3.1.1.RELEASE</org.springframework.version>  
   </properties> 


    <repositories>
        <repository>
            <id>java.net.2</id>
            <name>Java Net 2 Repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>apache.incubating</id>
            <name>Apache Incubating Repository</name>
            <url>http://people.apache.org/repo/m2-incubating-repository</url>
        </repository>
        <repository>
            <id>apache.snapshot</id>
            <name>Apache Snapshot Repository</name>
            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
        </repository>
        <repository>
        <id>thirdparty-releases</id>
        <name>JBoss Thirdparty Releases</name>
        <url>https://repository.jboss.org/nexus/content/repositories/thirdparty-releases</url>
      </repository>
    </repositories>

</project>

我正在摸索与maven相关的几个问题,并且由于这个错误,我已经搜索了很多,但我仍然无法找到解决方法。 有人可以帮帮我吗?

由于

1 个答案:

答案 0 :(得分:1)

不确定您是否已手动向maven lib添加任何内容... 在处理了涉及java.lang.NoClassDefFoundError的其他几个错误后,我遇到了同样的错误。按照我的习惯,我研究并将罐子放在maven lib中,这样它就可以找到它想要的类。似乎是明智的吗? 发生在另一个论坛上,一个人建议让maven解决依赖关系,而不是手动添加jar。我删除了我手动添加的所有罐子,然后再次尝试。显然maven找到了它所需要的东西,就像男人说的那样。该项目成功建成 我沿途也跑了几次mvn clean。不确定这是否有助于这种情况。 你可以说,我不是大师,但希望这有帮助