我有一个名为 sample-lib 的库,它依赖于 com.google.guava ,这里是pom.xml的一部分

<groupId>com.my</groupId>
<artifactId>sample-lib</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
...
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>16.0.1</version>
</dependency>

当我完成这个库时,我将它部署到我们的内部maven repo服务器(我们使用JFrog Artifactory) .

然后在我们的一个项目中我们使用 sample-lib ,我们在项目的pom.xml中引用它:

<dependency>
    <groupId>com.my</groupId>
    <artifactId>sample-lib</artifactId>
    <version>1.0</version>
</dependency>

因为我们认为 sample-lib 已经依赖谷歌 Guava ,所以我们不要使用pom文件 . 问题是当我们运行项目时,我们得到'class not found for com.google.guava.xxxx class' . 如果我们将guava依赖项添加到项目pom中,一切都可以 . 为什么我们 sample-lib 已经使用了 Guava 依赖无法解决?

我们发现一些开源项目不是这样的,当我们使用一个库时,我们将自动导入其所有依赖项 .

怎么会这样?在我们的 sample-lib 的pom文件中是否存在某些问题,或者我们的内部maven repo服务器出了什么问题?