How to add “Maven Managed Dependencies” library in build path eclipse?

后端 未结 15 1612
心在旅途
心在旅途 2020-12-04 11:04

I have created a Maven project and I want to add all Maven dependencies in build path of the project in Eclipse. When I go to Java Bui

相关标签:
15条回答
  • 2020-12-04 11:54

    If Maven->Update Project doesn't work for you? These are the steps I religiously follow. Remove the project from eclipse (do not delete it from workspace) Close Eclipse go to command line and run these commands.

    mvn eclipse:clean
    mvn eclipse:eclipse -Dwtpversion=2.0
    

    Open Eclipse import existing Maven project. You will see the maven dependency in our project.

    Hope this works.

    0 讨论(0)
  • 2020-12-04 11:54

    Likely quite simple but best way is to edit manually the file .classpath at the root of your project folder with something like

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
            <attributes>
                <attribute name="maven.pomderived" value="true"/>
                <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
            </attributes>
        </classpathentry>
    

    when you want to have jar in your WEB-IN/lib folder (case for a web app)

    0 讨论(0)
  • 2020-12-04 11:57

    I could figure out the problem. I was getting following warning on startup of eclipse.

    The Maven Integration requires that Eclipse be running in a JDK, because a number of Maven core plugins are using jars from the JDk.
    
    Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that
    Installed JRE's are also using JDK installs
    

    I changed eclipse.ini file and added following and restarted eclipse

    -vm
    C:/Program Files/java/jdk1.6.0_21/bin/javaw.exe
    

    Now I can see "Maven Dependency" library included automatically in java build path.

    0 讨论(0)
提交回复
热议问题