背景

在使用 Maven 构建项目的时候,我们有时候会发现,在 Maven 提供的 https://mvnrepository.com/ 这个网站搜索出来的依赖,有时候并搜索不出来我们想要的依赖。这时候可以在 https://search.maven.org/ 中结合精准查询使用。

场景一:知道用的什么类,如何找到 Maven 依赖

知道类的完整路径

搜索(其中 fc 代表 full class,知道类的完整路径的时候使用):

1
fc:com.google.common.collect.ImmutableSet

只知道类名

搜索(其中 c 代表 class,只知道类名的时候使用):

1
c:ImmutableSet

场景二:知道 Group ID 或者 Artifact ID,如何找到 Maven 依赖

知道 Group ID

搜索(其中 g 代表 group id,知道 group id 的时候使用):

1
g:com.alibaba

知道 Artifact ID

搜索(其中 a 代表 artifact id,知道 artifact id 的时候使用):

1
a:druid