简体   繁体   English

在Eclipse中导入Maven项目时出错

[英]Error importing Maven project in eclipse

I have a problem which I do not know how to solve. 我有一个我不知道如何解决的问题。 I want to import a maven project to eclipse. 我想导入一个Maven项目来蚀。 However when I am doing so I am getting following error from eclipse: 但是,当我这样做时,我从Eclipse中收到以下错误:

在此处输入图片说明

But when I am doing "mvn install" in the terminal, I am able to successfully build the project. 但是,当我在终端中执行“ mvn install”时,我能够成功构建项目。 Here is the pom.xml file: 这是pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<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.thinkaurelius.titan</groupId>
    <artifactId>titan-web-example</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <description>
        This is a simple web app example.
    </description>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <properties>
        <spring.version>4.0.3.RELEASE</spring.version>
        <titan.version>1.0.0</titan.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-cassandra</artifactId>
            <version>${titan.version}</version>
            <exclusions>
                <!-- These don't play well w/ the web classesthatrunthings deps below -->
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-es</artifactId>
            <version>${titan.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>3.0.0-incubating</version>
        </dependency>


        <!-- Web App -->
        <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.jboss.resteasy</groupId>
            <artifactId>jaxrs-api</artifactId>
            <version>2.2.1.GA</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.18.1</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.18.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Jersey -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.18.1</version>
            <exclusions>
                <!-- oh maven you crazy old bird! -->
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Jetty Embedded App Container -->
        <!-- You only need this if you want to run the web app in the embedded jetty container using the RunApp class -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.2.0.v20140526</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.2.0.v20140526</version>
        </dependency>

        <!-- Util -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>

        <!-- Groovy GMaven -->
        <dependency>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.4</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>titan-web-example</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <providerSelection>1.8</providerSelection>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>generateTestStubs</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>

It looks like gmaven has a problem in eclipse, but I do not know how to solve that. 看来gmaven在Eclipse中有问题,但是我不知道该如何解决。

The way Eclipse handles Maven projects is currently through the m2e plugin. Eclipse处理Maven项目的方式目前是通过m2e插件实现的。

m2e does not invoking Maven underneath, but parses the pom.xml files and for each plugin mentioned invoke code explicitly written to behave identically inside m2e as the plugin. M2E 调用Maven的下方,但解析的pom.xml文件,并为每个插件提到调用代码明确写入相同的行为M2E里面的插件。 This is what a "connector" is. 这就是“连接器”。

If a connector is not available for a given plugin (so m2e could emulate it for you) you see this error. 如果连接器不适用于给定的插件(因此m2e可以为您模拟),则会看到此错误。 This is unfortunately not uncommon for the more rare plugins. 不幸的是,这对于较罕见的插件来说并不罕见。

You must investigate to see if it is enough for m2e to be able to present enough of the project to allow you to work anyway, and then just do real builds from the command line. 您必须进行调查,以查看m2e是否足以显示足够的项目以允许您继续工作,然后再从命令行进行实际构建。

You may also consider using another free IDE for such a troublesome project. 您也可以考虑将另一个免费的IDE用于此类麻烦的项目。 I know that IntelliJ works with almost any pom.xml file, and am told that Netbeans can too. 我知道IntelliJ几乎可以处理任何pom.xml文件,并且被告知Netbeans也可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM