Friday, December 19, 2008

Easy dependency management with m2eclipse

If you've ever used Maven, or are currently using it, you know that most of the time, it can be a pain to add a new dependency.

So you know how it goes. You need a new JAR; you fire up your browser of choice, go to the central repository and hunt for the jar that you need. You finally find it after digging through all the folders, then open up pom.xml and add the group id, artifact id, optional version number, etc., and finally, run maven to get the new jar.
Easy huh? ;)

With the m2eclipse plugin, (available at, you no longer have to go through that multi-step process.

If you haven't added the update site before, you'll have to add it manually.
1. Go to Help -> Software Updates -> Find and install
2. Choose the "Search for new features to install" option and click Next
3. Click "New Remote Site..."
4. Enter "m2eclipse" for the name and enter the URL

Now you add dependencies automatically when:
Right clicking on the project and going to Maven -> Add dependency.
During coding: code as you normally do, and when Eclipse complains that the class can't be found, you can click on the red "x" and find the dependency by going through the central repository!

In the example below, I added the @RequestMapping annotation to my Spring 2.5 Controller, and since I didn't have the jar in my local repository, Eclipse notified me of the error. (Figure 1)

Clicking on "Search dependency for RequestMapping" then searched the repository, and provided a listing of potential matching jars. Select the one you want and the rest is automatically taken care of! (Figure 2)

Figure 1: Clicking on the red "x" brings up a context menu where you can search the Maven central repository

Figure 2: The class name is automatically entered, and a list of jars that contain that class is shown.

m2eclipse will take care of downloading the required jars and adding them to your classpath. That's it!

Friday, December 12, 2008

SpringOne 2008

I missed The Spring Experience 2007, but was able to return in 2008, and it has been renamed to springOne. During Adrian Colyer's keynote, he posted this hilarious photo:
Yes, that's the Rod Johnson bobblehead doll! I'm so jealous of everyone who was able to attend in 2007. Hopefully they give out something like this in 2009.

On a more serious note, some of the highlights of the conference:

Managing the war on complexity: This was the theme of Rod Johnson's keynote, and I'm glad he explicitly said this, as Spring is truly one of the best solutions to making Java EE web apps simple to maintain and develop.

OSGi: Becoming very popular, and something worth looking into.

Spring MVC: The old Controller hierarchy is going away, and moving towards the annotation based Controllers found in 2.5. Also, Spring 3.0 will have native REST support!

Grails: If you follow the Grails scene, then you know that G2One, the company behind Grails, has been acquired by SpringOne. Rod just reiterated this to let the community know that Grails will have even better Spring support now that they are the same company.