Ir al contenido principal

Using Maven just for dependency management

For quite some time now I've had the intention to learn how to use Maven and especially how to use it to manage the dependencies for my projects without having to do anything special. I share with you what is necessary to achieve the same thing in your own projects.

First we need to have Maven installed.  You can download Maven from Here so you can execute it from the console or you can install the plugin for eclipse, just search for a plugin called "m2e - Maven Integration for Eclipse" in eclipse and install it.

The next thing to do is to replace the commented code in the "pom.xml" by following the steps below:
  • The, can be for example the package name of the project in which you use the pom for example com.domain.project.
  • The artifact-id, might be something like domain-project (for domain-project.jar) or project (for project.jar) without taking into account the version.  So for commons-logging-1.1.1.jar for example the artifact id would be commons-logging.
  • Replace the string "libs" inside <libraries.folder>libs</libraries.folder> with the path in which you want the jars to be stored. For a website project developed using Eclipse it could be for example something like "WebContent/WEB-INF/lib".
  • Locate the piece of xml below and add the dependencies you want to be automatically managed by Maven.  In this Url you can search for the dependencies you wish to add.
<!-- Your dependencies -->
<groupId>group id</groupId>
<artifactId>artifact id</artifactId>
<version>the version number!</version>
  • And finally add the repositories you need, generally you do not need to configure any additional repositories, however, there are times in which the jar that we are looking for is not in a general repository so we might get a problem that says "Could not resolve dependencies for project" and "Could not find artifact", in this case we must find out which is the repository where the jar is located and then add the repositories where the following piece of xml is located.
<!-- Your repositories -->
<id>Repo ID</id>
<name>Repo Name</name>

The file “pom.xml” is designed so that nothing else is necessary to be added in order to run it, just type “mvn” from within the path where the “pom.xml” is located and then press enter or from within Eclipse right click the pom, “Run As”, “Maven Build” and then clicking the “Run” button will start the execution.  At this point Maven will create a folder, if it doesn't exist already, and it will download all the jars that you added and their respective dependencies.

Here is the complete code:

Well, I hope this post has been helpful.


Entradas populares de este blog

Create a custom AEM workflow process step with a dialog

In this tutorial I talk about how to create a custom workflow step process with an additional dialog for configuring it, above is the vid and below you will find some useful notes. 1. Pre-reqs Have access to an Adobe Experience Manager instance. Have Maven installed, understand how it works and also understand how to use Adobe's archetype, you can watch my video about maven here: Creating an AEM application using Maven and Adobe's archetype 2. What is an AEM Workflow and workflow model Workflows allow you to automate different tasks inside AEM by defining a s

Creating Docker containers for Adobe Experience Manager

This is a Docker tutorial for creating a docker image for the Galen framework, above is the vid and below you will find some of the steps followed. Adobe experience manager is a content management system which in a nutshell is an application that allows us to create web sites to be consumed by end users. You might be familiar with other such applications like wordpress or drupal which serves the same purpose A typical deployment would be comprised of two AEM instances, the author instance used for creating and modifying content, the publish instance which serves the content and finally we have a dispatcher which is a static web server used for caching, load balancing and some security purposes. We can configure an AEM instance to work as an author or publish instance by either changing the file name

Creating a Mongo replicaset using docker: Mongo replicaset + Nodejs + Docker Compose

This is a Docker tutorial for creating a Mongo replica set using docker compose and also a couple more containers to experiment with the replica set, above is the vid and below you will find some of the steps followed. Steps Pre-reqs Have node.js installed And docker installed (make sure you have docker-compose as well) Create a container for defining configurations for a mongo instance Create a container for setting up the replica set Create a simple node app using expressjs and mongoose (A modified version from the previous video ) Create a docker-compose file with the mongo and setup containers and two additional containers for experimenting with the replica set Build, Run and experiment with your new containers Create a dockerfile for the first mongo container (not really needed but you could configure more stuff if needed) Include container with mongo preinstalled:  FROM mongo Create default/working directory:  WORKDIR /usr/src/configs Copy mongo