YouTip LogoYouTip

Maven Eclipse

The latest version of Eclipse comes with Maven built-in. Open it and go to Windows->Preferences. If you see the following screen: !(#) Here are some features of m2eclipse: * You can run Maven goals within the Eclipse environment. * You can use its built-in console to view the output of Maven commands directly in Eclipse. * You can update Maven dependencies within the IDE. * You can use Eclipse to build Maven projects. * Eclipse automates dependency management based on Maven's pom.xml. * It resolves dependencies between Maven and the Eclipse workspace without needing to install them into the local Maven repository (requires the dependent project to be in the same workspace). * It can automatically download required dependencies and source code from remote Maven repositories. * It provides wizards for creating new Maven projects, pom.xml files, and enabling Maven support on existing projects. * It offers quick search for dependencies in remote Maven repositories. ### Importing a Maven Project into Eclipse * Open Eclipse * Select **File > Import** option * Select the Maven Projects option. Click the Next button. !(#) * Select the project path, which is the storage path when creating a project with Maven. Assume we have created a project: consumerBanking. See [**Maven Creating Java Project**](#) to learn how to create a project with Maven. * Click the Finish button. !(#) Now, you can see the Maven project in Eclipse. !(#) Look at the properties of the consumerBanking project, and you will find that Eclipse has added all Maven dependencies to its build path. !(#) Alright, let's build this Maven project using Eclipse's compilation feature. * Right-click to open the context menu of the consumerBanking project * Select the Run option * Then select the maven package option Maven starts building the project, and you can see the output log in Eclipse's console. Scanning for projects... ------------------------------------------------------------------- Building consumerBanking Id: com.companyname.bank:consumerBanking:jar:1.0-SNAPSHOT task-segment: ------------------------------------------------------------------- [resources:resources] Using default encoding to copy filtered resources. [compiler:compile] Nothing to compile - all classes are up to date [resources:testResources] Using default encoding to copy filtered resources. [compiler:testCompile] Nothing to compile - all classes are up to date [surefire:test] Surefire report directory: C:MVNconsumerBankingtargetsurefire-reports ------------------------------------------------------- T E S T S -------------------------------------------------------Running com.companyname.bank.AppTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec Results :Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [jar:jar] ------------------------------------------------------------------- BUILD SUCCESSFUL ------------------------------------------------------------------- Total time: 1 second Finished at: Thu Jul 12 18:18:24 IST 2012 Final Memory: 2M/15M ------------------------------------------------------------------- !(#) Now, right-click on **App.java**, select the **Run As** option. Choose **As Java App** You will see the following result: Hello World!
← Maven IntellijMaven Deployment Automation β†’