Dependent classes missing in jar when using maven compile scope

Viewed 266

My java project name is tmcloud, which using maven3, and in the pom.xml file I used the following dependency:

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

I thought that because of I used maven compile scope, the classes in commons-lang3 would be included in my final jar tmcloud-1.1.jar when I used command maven clean install, but I didn't find any classes of commons-lang3 in tmcloud-1.1.jar.

1 Answers

maven doesn't include the dependencies in the jar by default. The dependencies are set to be available on the classpaths of your project.

If you want to have a self containing jar, that includes the dependant jars, you will have to use a plugin like the maven-shade-plugin.

Related