无法在项目上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli):命令执行失败

时间:2016-01-21 13:14:25

标签: java spring maven netbeans

我使用外部maven在Netbeans中创建了一个maven java项目。 Maven版本是3.3.9,jdk1.7.0.45。 Netbeans 7.4。该项目已成功构建,但运行失败并出现以下错误。是因为exec-maven-plugin的错误版本?谁能告诉我如何解决这个问题?谢谢高级

--- maven-resources-plugin:2.6:resources (default-resources) @ owlapitest2 ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\java project\owlapitest2\src\main\resources

--- maven-compiler-plugin:2.5.1:compile (default-compile) @ owlapitest2 ---
Nothing to compile - all classes are up to date

--- exec-maven-plugin:1.2.1:exec (default-cli) @ owlapitest2 ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.maximumSize(J)Lcom/google/common/cache/CacheBuilder;
    at org.semanticweb.owlapi.model.IRI.<clinit>(IRI.java:318)
    at org.semanticweb.owlapi.vocab.OWLFacet.<init>(OWLFacet.java:71)
    at org.semanticweb.owlapi.vocab.OWLFacet.<clinit>(OWLFacet.java:39)
    at org.semanticweb.owlapi.vocab.OWL2Datatype$Category.<clinit>(OWL2Datatype.java:270)
    at org.semanticweb.owlapi.vocab.OWL2Datatype.<clinit>(OWL2Datatype.java:38)
    at uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryInternalsImplNoCache.<clinit>(OWLDataFactoryInternalsImplNoCache.java:32)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:86)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:108)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:259)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:107)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:259)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1018)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:94)
    at com.google.inject.Guice.createInjector(Guice.java:71)
    at com.google.inject.Guice.createInjector(Guice.java:61)
    at org.semanticweb.owlapi.apibinding.OWLManager.createInjector(OWLManager.java:89)
    at org.semanticweb.owlapi.apibinding.OWLManager.instatiateOWLOntologyManager(OWLManager.java:97)
    at org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager(OWLManager.java:58)
    at com.mycompany.owlapitest2.App.main(App.java:19)

BUILD FAILURE

Total time: 5.371 s
Finished at: 2016-01-21T20:51:15+08:00
Final Memory: 9M/23M

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project owlapitest2: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
-------------------------------------------------------------------------------
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
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.mycompany</groupId>
  <artifactId>owlapitest2</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>owlapitest2</name>
  <url>http://maven.apache.org</url>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven.shared</groupId>
      <artifactId>maven-filtering</artifactId>
      <version>3.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>3.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-install-plugin</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>classworlds</groupId>
      <artifactId>classworlds</artifactId>
      <version>1.1-alpha-2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>3.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-settings</artifactId>
      <version>3.0.5</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.12.4</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>
      <version>2.6</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-clean-plugin</artifactId>
      <version>2.5</version>
    </dependency>
    <dependency>
      <groupId>net.sourceforge.owlapi</groupId>
      <artifactId>owlapi-distribution</artifactId>
      <version>4.1.0</version>
      <type>jar</type>
    </dependency>
  </dependencies>
</project>
package com.mycompany.owlapitest2;

import java.io.File;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.util.SimpleIRIMapper;

public class App 
{
    public static void main( String[] args ) throws OWLOntologyCreationException
    {
         OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

        // Load an ontology from the Web
        IRI iri = IRI.create("http://acrab.ics.muni.cz/ontologies/swrl_tutorial.owl");
        OWLOntology personOntology = manager.loadOntologyFromOntologyDocument(iri);
        System.out.println("Loaded ontology: " + personOntology);

        // Remove the ontology so that we can load a local copy.
        manager.removeOntology(personOntology);

       // We can also load ontologies from files. Create a file object that points to the local copy
        File file;
        file = new File("C:\\Users\\zyy\\ontologies\\reference ontologies\\pizza.owl");

        // Load the local copy
        OWLOntology localPizza = manager.loadOntologyFromOntologyDocument(file);
        System.out.println("Loaded ontology: " + localPizza);

        // Remove the ontology again so we can reload it later
         manager.removeOntology(personOntology);

        // When a local copy of one of more ontologies is used, an ontology IRI mapper can be used
        // to provide a redirection mechanism. This means that ontologies can be loaded as if they
        // were located on the Web. In this example, we simply redirect the loading from
        // http://www.co-ode.org/ontologies/pizza/pizza.owl to our local copy above.
         manager.addIRIMapper(new SimpleIRIMapper(iri, IRI.create(file)));

       // Load the ontology as if we were loading it from the Web (from its ontology IRI)
          IRI pizzaOntologyIRI = IRI.create("http://www.co-ode.org/ontologies/pizza/pizza.owl");
          OWLOntology redirectedPizza = manager.loadOntology(pizzaOntologyIRI);

          System.out.println("Loaded ontology: " + redirectedPizza);
          System.out.println(" from: " + manager.getOntologyDocumentIRI(redirectedPizza));
    }
}

1 个答案:

答案 0 :(得分:1)

根据堆栈跟踪,调用at com.mycompany.owlapitest2.App.main(App.java:19)后发生异常,因此可能不是maven的问题,而是应用程序中的问题。

根据Exception,看起来你的代码是为其他版本的Guava编译的,那么你在运行时就已经在类路径中了。