Pages

Sunday, August 11, 2013

Maven - A great tool

Let's say you are going to make a project that uses MySQL as a database and Hibernate as a persistence tool. Importing the jars of those into Eclipse can be hard and challenging sometimes. At this point, Maven shows up and gives a hand. What Maven does is downloading the dependencies of the project automatically.


How can it do this? Well, when you create a maven project, it generates pom.xml file. You are going to write dependencies (the jars that our project needs) of your project into pom.xml and Maven will do the rest. In pom.xml, you have to write dependencies in a certain template which is:

<dependency>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
</dependency>

But how can you fill this template? At this point Maven Repository saves our lives. You will search what you need for your project in that website. After choosing the version you want, you will see a page that shows the filled template for your pom.xml (for example: mysql-connector). Finally when you update the project, you will see that dependencies are added.

You can download Maven plugin to your Eclipse as applying followings:
  • Go to Help->Install New Software...
  • Paste this link to the Work with: area.
  • And you're done.

No comments:

Post a Comment