Find the Maven artifact that contains a class


Say you have a java project that doesn't compile because of a missing dependency:

$ mvn compile
[..]
[ERROR] /home/torstein/src/foo-app/src/main/java/com/example/Event.java:[165,47] cannot access javax.ws.rs.sse.InboundSseEvent
  class file for javax.ws.rs.sse.InboundSseEvent not found

Now, how do you figure out what dependency to add to your pom.xml?

Easy, head over to:

https://search.maven.org/search?q=fc:<class>

So for us here, that means hitting https://search.maven.org/search?q=fc:javax.ws.rs.sse.InboundSseEvent

Searching your local Maven repository

You can also search your local Maven repository for artifact that matches:

$ grep -r --fixed-strings javax.ws.rs.sse.InboundSseEvent ~/.m2/repository/

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐦 @torsteinkrause ~