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/

~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert