简体   繁体   中英

Maven Eclipse Integration Issue

I am having an issue with Maven integration. I have recently downloaded Eclipse Luna (with JDK 8 patch) and using it on Ubuntu OS.

I have created a Maven project with simple artifact and now when I add write some dependency in my pom.xml file and then test it, the Maven build is successful, but in my Java build path, the JRE System Libraries [J2SE-1.5 ] is present but my Maven Dependencies does not contain anything in spite of writing a few dependencies in my POM.xml file.

This is my pom.xml file

<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.test</groupId>
    <artifactId>testproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>org.apache.lucene</groupId>
                <artifactId>lucene-core</artifactId>
                <version>5.0.0</version>
            </dependency>

            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.10-FINAL</version>
            </dependency>

        </dependencies>

    </dependencyManagement>


</project>

Due to my Maven dependencies being not present in my build path, hence, I am not able to use the libraries which are to be added by Maven.

you have to put the dependencies outside of <dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>5.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>

    </dependencies>

see the documentation for what <dependencyManagement> should be used:

The dependency management section is a mechanism for centralizing dependency information. When you have a set of projects that inherits a common parent it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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