无法从控制台运行Maven

时间:2013-01-28 12:07:20

标签: java eclipse maven-3

我已从this blog post下载了示例的源代码,我想将其导出到Tomcat。我“几乎”成功地将项目导入Eclipse,几乎是因为Eclipse没有将项目视为Web项目。

好的我仍然可以从控制台编译WAR而不是从IDE导出。

相反,我从控制台尝试了mvn package但是我收到了一个错误:

djechelon@RAYNOR:~/workspace/rest-sample> mvn package
28/gen/2013 12:54:47 com.google.inject.internal.MessageProcessor visit
INFO: An exception was caught and reported. Message: java.util.NoSuchElementException
java.util.NoSuchElementException
   at java.util.AbstractList$2.next(libgcj.so.13)
   at com.google.inject.spi.InjectionPoint.forMember(InjectionPoint.java:116)
   at com.google.inject.spi.InjectionPoint.<init>(InjectionPoint.java:73)
   at com.google.inject.spi.InjectionPoint$InjectableMethod.toInjectionPoint(InjectionPoint.java:459)
   at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:725)
   at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
   at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:377)
   at com.google.inject.internal.BindingBuilder.toInstance(BindingBuilder.java:84)
   at org.codehaus.plexus.DefaultPlexusContainer$ContainerModule.configure(DefaultPlexusContainer.java:803)
   at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
   at com.google.inject.spi.Elements.getElements(Elements.java:103)
   at com.google.inject.spi.Elements.getElements(Elements.java:80)
   at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
   at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
   at com.google.inject.spi.Elements.getElements(Elements.java:103)
   at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
   at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
   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.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
   at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
   at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
   at org.apache.maven.cli.MavenCli.container(MavenCli.java:375)
   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:191)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
   at java.lang.reflect.Method.invoke(libgcj.so.13)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
   at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
   at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
28/gen/2013 12:54:47 com.google.inject.internal.MessageProcessor visit
INFO: An exception was caught and reported. Message: java.util.NoSuchElementException
java.util.NoSuchElementException
   at java.util.AbstractList$2.next(libgcj.so.13)
   at com.google.inject.spi.InjectionPoint.forMember(InjectionPoint.java:116)
   at com.google.inject.spi.InjectionPoint.<init>(InjectionPoint.java:73)
   at com.google.inject.spi.InjectionPoint$InjectableMethod.toInjectionPoint(InjectionPoint.java:459)
   at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:725)
   at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
   at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:377)
   at com.google.inject.internal.BindingBuilder.toInstance(BindingBuilder.java:84)
   at org.codehaus.plexus.DefaultPlexusContainer$DefaultsModule.configure(DefaultPlexusContainer.java:836)
   at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
   at com.google.inject.spi.Elements.getElements(Elements.java:103)
   at com.google.inject.spi.Elements.getElements(Elements.java:80)
   at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
   at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
   at com.google.inject.spi.Elements.getElements(Elements.java:103)
   at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
   at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
   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.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
   at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
   at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
   at org.apache.maven.cli.MavenCli.container(MavenCli.java:375)
   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:191)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
   at java.lang.reflect.Method.invoke(libgcj.so.13)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
   at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
   at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR] Error executing Maven.
[ERROR] null

以上错误适用于任何Maven项目。我首先尝试从unstable package安装Maven 3,然后卸载它,从Apache下载官方Maven 3并再次使用主目录中的新包(因此我没有运行mvn但是{{ 1}}):同样的错误。

但是,如果我从Eclipse STS(/home/djechelon/apache-mvn------/bin/mvn - &gt; Spring Tools)运行Maven,我没有收到任何错误,它会更新Eclipse的所有依赖项(但不会使项目成为Web项目)。

如何解决问题并将WAR部署到Tomcat?

[添加] pom.xml的内容

Update Maven dependencies

[编辑] Java版

<?xml version="1.0"?>
<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">
    <artifactId>rest-sample</artifactId>
    <modelVersion>4.0.0</modelVersion>
    <inceptionYear>2011</inceptionYear>
    <packaging>war</packaging>
    <groupId>com.blog.rest</groupId>
    <version>1.0</version>
     <properties>
        <releaseCandidate>1</releaseCandidate>
        <spring.version>3.1.1.RELEASE</spring.version>
        <java.version>1.5</java.version>
        <jackson.mapper.version>1.5.6</jackson.mapper.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.javadoc.reporting.version>2.7</maven.javadoc.reporting.version>
        <commons.logging.version>1.1.1</commons.logging.version>
        <log4j.version>1.2.16</log4j.version>
        <context.path>rest-sample</context.path>
        <jackson.mapper.version>1.5.6</jackson.mapper.version>
    </properties>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warName>${context.path}</warName>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
    <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>${jackson.mapper.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
        </dependency>
    </dependencies>
</project>

0 个答案:

没有答案