Developing with Eclipse and Maven

6.2. Searching For Maven Artifacts and Java classes

6.2. Searching For Maven Artifacts and Java classes

m2eclipse adds a couple of items to the Eclipse Navigation menu that make searching for Maven Artifacts and Java classes easy work. Each option is available by clicking on the Navigate menu as shown in Figure 6.1, “Searching for Artifacts and Classes”:

Searching for Artifacts and Classes

Figure 6.1. Searching for Artifacts and Classes


Notice the available options in Figure 6.1, “Searching for Artifacts and Classes” under the Eclipse Navigate menu named Open Maven POM and Open Type from Maven. The Open Maven POM option allows you to search the Maven repository for a given POM as shown in Figure 6.2, “Searching for a POM”:

Searching for a POM

Figure 6.2. Searching for a POM


Upon selecting an artifact and clicking OK, the POM for that artifact is opened in Eclipse for browsing or editing. This is handy when you need to take a quick look at the POM for a given artifact.

The second m2eclipse option in the Navigate menu is named Open Type from Maven. This feature allows you to search for a Java class by name in a remote repository. Upon opening this dialog, simply type ‘factorybean’ and you’ll see many classes with the name FactoryBean in them as shown in Figure 6.3, “Searching the Repository for a Class”:

Searching the Repository for a Class

Figure 6.3. Searching the Repository for a Class


This is a big time saving feature because it means that manually searching through artifacts in a Maven repository for a particular class is a thing of the past. If you need to use a specific class, just fire up Eclipse, go to the Navigate menu and search for the class. m2eclipse will show you the list of artifacts in which it appears.