使用Maven编译范围时jar中缺少依赖类

时间:2019-01-17 21:10:16

标签: maven

我的Java项目名称是tmcloud,它使用maven3,在pom.xml文件中,我使用了以下依赖项:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.7</version>
    <scope>compile</scope>
</dependency>

我认为由于使用了maven编译范围,所以当我使用命令maven clean install时,commons-lang3中的类将包含在最终的jar tmcloud-1.1.jar中,但是我没有找到任何类tmcloud-1.1.jar中的commons-lang3。

1 个答案:

答案 0 :(得分:1)

默认情况下,maven不将依赖项包含在jar中。依赖项设置为在项目的类路径上可用。

如果您想拥有一个包含相关jar的自包含jar,则必须使用maven-shade-plugin之类的插件。

相关问题