Question: I have a Spring Boot application and I have created a Jar out of that. Following is my `pom.xml`:

```
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-java8time</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <!-- WebJars -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6.2</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

```

I want to use this Jar in my other application so added this jar to my application. But when I am calling a method in that Jar, it is throwing a `ClassNotFoundException`.

How can I fix this issue? How can I add a dependency to a Spring Boot JAR?

Answer: 
For Spring Boot 2 @Tunaki's answer must be modified a bit according to the [documentation](https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/maven-plugin/examples/repackage-classifier.html) if `spring-boot-starter-parent` is used as parent :

```
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>repackage</id>
        <configuration>
          <classifier>exec</classifier>
        </configuration>
      </execution>
    </executions>

```

Take note of the extra `<id>repackage</id>` necessary to overwrite to execution from the `spring-boot-starter-parent`.
use below plugin for spring boot version 2.\*

```
<plugin>
     <groupId>org.springframework.boot</groupId>           
     <artifactId>spring-boot-maven-plugin</artifactId>
     <version>2.2.1.RELEASE</version>
     <configuration>
          <classifier>exec</classifier>
     </configuration>
</plugin>

```