繁体   English   中英

Eclipse无法构建Maven多模块项目

[英]Eclipse fails to build maven multi-module project

我正在尝试在Eclipse中构建多模块Maven项目,但是在Eclipse Oxygen中遇到了8670个Java Problems 我的项目有一个父项目,其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>org.neo4j</groupId>
<artifactId>graph-algorithms-parent</artifactId>
<version>3.3.2.0</version>
<packaging>pom</packaging>
<name>Neo4j Graph Algorithms</name>
<description>Efficient Graph Algorithms for Neo4j</description>

<profiles>
    <profile>
        <id>Benchmark</id>
        <modules>
            <module>benchmark</module>
        </modules>
    </profile>
</profiles>

<modules>
    <module>core</module>
    <module>algo</module>
    <module>tests</module>
</modules>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <neo4j.version>3.3.1</neo4j.version>
    <jmh.version>1.19</jmh.version>
    <javac.target>1.8</javac.target>
</properties>

<organization>
    <name>Neo4j, Inc.</name>
    <url>https://neo4j.com</url>
</organization>

<developers>
    <developer>
        <id>neo-technology</id>
        <organization>Neo4j, Inc.</organization>
        <url>https://neo4j.com</url>
    </developer>
    <developer>
        <id>avgl</id>
        <organization>Avantgarde Labs GmbH</organization>
        <url>https://avantgarde-labs.de</url>
    </developer>
</developers>

<url>https://github.com/neo4j-contrib/neo4j-graph-algorithms</url>

<scm>
    <url>https://github.com/neo4j-contrib/neo4j-graph-algorithms</url>
</scm>

<licenses>
    <license>
        <name>GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007</name>
        <url>https://www.gnu.org/licenses/gpl.txt</url>
        <comments>
            Note that this license is for the project itself, and not for its dependencies.
            See the included NOTICE.txt file for further details.
        </comments>
        <distribution>repo</distribution>
    </license>
</licenses>


<dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>${neo4j.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-kernel</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-io</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.biville.florent</groupId>
            <artifactId>neo4j-sproc-compiler</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <!-- Benchmark Dependencies -->
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>${jmh.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>${jmh.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>


<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <!-- Neo4j Procedures require Java 8 -->
                <compilerVersion>${javac.target}</compilerVersion>
                <source>${javac.target}</source>
                <target>${javac.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.9.1</version>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
               <additionalparam>-Xdoclint:none</additionalparam>
            </configuration>
        </plugin>
       <plugin>
           <groupId>org.asciidoctor</groupId>
           <artifactId>asciidoctor-maven-plugin</artifactId>
           <version>1.5.3</version>
           <inherited>false</inherited>
           <executions>
               <execution>
                   <id>generate-docs</id>
                   <phase>package</phase>
                   <goals>
                       <goal>process-asciidoc</goal>
                   </goals>
               </execution>
           </executions>
           <configuration>
               <backend>html5</backend>
               <!--preserveDirectories>true</preserveDirectories -->
               <imagesDir>images</imagesDir>
               <sourceDirectory>${basedir}/doc</sourceDirectory>
               <sourceDocumentName>index.adoc</sourceDocumentName>
               <outputDirectory>${basedir}/target/docs</outputDirectory>
               <attributes>
                   <neo4j-version>${project.version}</neo4j-version>
               </attributes>
               <requires>
                   <require>asciidoctor-diagram</require>
               </requires>
               <source-highlighter>coderay</source-highlighter>
               <coderay-css>style</coderay-css>
           </configuration>
           <dependencies>
           <dependency>
               <groupId>org.asciidoctor</groupId>
               <artifactId>asciidoctorj-diagram</artifactId>
               <version>1.3.1</version>
           </dependency>
           </dependencies>
       </plugin>
        <plugin>
            <groupId>com.mycila.maven-license-plugin</groupId>
            <artifactId>maven-license-plugin</artifactId>
            <version>1.10.b1</version>
            <configuration>
                <header>gplv3-header.txt</header>
                <strictCheck>true</strictCheck>
                <failIfMissing>true</failIfMissing>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

然后,我有4个子模块benchmarkcorealgotests ,它们各自的pom.xml都正确地引用了父项目(具有正确的版本号)。 实际的项目来自neo4j ,您可以在这里找到。

我尝试执行maven clean install ,项目成功构建,没有任何问题。 但是,当我将项目导入Eclipse时,我遇到很多错误(主要是来自父项目),指出... cannot be resolved to a type... cannot be resolved

我尝试做一个Maven > Update Project但没有成功。 我在Eclipse的Project Explorer视图中,所有5个项目都处于同一级别。

我也尝试在Eclipse中添加Active Maven Profiles ,但是并不能解决问题。 我的嵌入式Maven版本是3.3.9 / 1.8.2.20171007-0216

我发现了问题。 问题是,我的Eclipse工作区是名为workspace区的目录。 但是,我的maven项目位于我创建的子文件夹my_project 当我克隆回购协议,我cdmy_project ,做git clone

因此,我没有选择最高级别的workspace文件夹作为我的Eclipse工作空间,而是选择了/workspace/my_project作为工作空间,问题得到了解决。

暂无
暂无

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

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