[Chapter 18] - Maven Eclipse's b2b2c e-commerce technology summary of Spring Cloud live mall

Posted by Mr Chew on Wed, 24 Nov 2021 05:10:09 +0100

Maven Eclipse

Eclipse provides a good plug-in   m2eclipse   , the plug-in can integrate Maven and Eclipse.

Maven is included in the latest Eclipse. Let's open windows - > preferences. If so, the following screen will appear:

Here are some features of m2eclipse:

  • You can run Maven's target files on the Eclipse environment.
  • You can use its own console to directly view the output of Maven commands in Eclipse.
  • Maven dependencies can be updated under the IDE.
  • You can use Eclipse to build Maven projects.
  • Eclipse implements automated dependency management based on Maven's pom.xml.
  • It solves the dependency between Maven and Eclipse workspaces without installing into the local Maven repository (the dependent projects need to be in the same workspace).
  • It can automatically download the required dependencies and source code from the remote Maven library.
  • It provides a wizard to create a new Maven project, pom.xml, and enable Maven support on existing projects.
  • It provides a fast search of the dependencies of the remote Maven repository.

Import a Maven project in Eclipse

  • Open Eclipse
  • choice   File > Import  > option
  • Select the Maven Projects option. Click the Next button.

  • Select the path of the project, that is, the storage path when creating a project using Maven. Suppose we create a project: consumerBanking   Maven build Java project   See how to create a project using Maven.
  • Click the Finish button.

Now you can see the Maven project in Eclipse.

Looking at the properties of the consumerBanking project, you can see that Eclipse has added Maven's dependencies to its build path.

Well, let's use Eclipse's compilation capabilities to build the Maven project.

  • 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 the Eclipse console.

[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building consumerBanking
[INFO] Id: com.companyname.bank:consumerBanking:jar:1.0-SNAPSHOT
[INFO] task-segment: [package]
[INFO] -------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: 

 T E S T S
Running com.companyname.bank.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar]
[INFO] -------------------------------------------------------------------
[INFO] -------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Jul 12 18:18:24 IST 2012
[INFO] Final Memory: 2M/15M
[INFO] -------------------------------------------------------------------

Right click now   App.java, select   Run As   Options. choice   As Java App

You will see the following results:

Hello World!

Topics: Eclipse Maven Spring Cloud