How to build and run Maven projects after importing into Eclipse IDE

前端 未结 7 1492
时光取名叫无心
时光取名叫无心 2020-12-02 09:35

I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder

相关标签:
7条回答
  • 2020-12-02 09:40

    1.Update project

    Right Click on your project maven > update project

    2.Build project

    Right Click on your project again. run as > Maven build

    If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.

    You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.

    i.e, “clean install” for building purpose

    Click apply

    Click run.

    3.Run project on tomcat

    Right Click on your project again. run as > Run-Configuration. It will open Run-Configuration window for you.

    Right Click on “Maven Build” from the right side column and Select “New”. It will open a blank configuration for you.

    Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.

    If you want to get more clear idea with snapshots use the following link.

    Build and Run Maven project in Eclipse

    (I hope this answer will help someone come after the topic of the question)

    0 讨论(0)
  • 2020-12-02 09:42

    Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".

    0 讨论(0)
  • 2020-12-02 09:43
    1. Right Click on your project
    2. Go to Maven>Update Project
    3. Check the Force Update of Snapshots/Releases Checkbox
    4. Click Ok

    That's all. You can see progression of build in left below corner.

    0 讨论(0)
  • 2020-12-02 09:53

    Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification. Maven Project Update based on changes on pom.xml

    0 讨论(0)
  • 2020-12-02 10:00

    I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.

    Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.

    M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.

    0 讨论(0)
  • 2020-12-02 10:01

    When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.

    You can search dependency artifacts at http://mvnrepository.com/

    And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.

    Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.

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