Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy dependencies in a spring boot application

I have spring boot application where during maven install, I want it to create a jar and copy the dependencies into a lib folder. I am trying to use these two maven plugins that are working fine in other maven projects but doesn't work in a spring boot application.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
           <useDefaultManifestFile>true</useDefaultManifestFile>
           <archive>
              <manifest>
                 <addClasspath>true</addClasspath>
                 <mainClass>xxx.Main</mainClass>
                 <classpathPrefix>lib/</classpathPrefix>
              </manifest>
           </archive>
        </configuration>
     </plugin>
     <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
           <execution>
              <phase>install</phase>
              <goals>
                 <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                 <outputDirectory>${project.build.directory}/lib</outputDirectory>
              </configuration>
           </execution>
        </executions>
     </plugin>

What is happening is that the jar gets created even if the maven-jar-plugin is omitted. And it doesn't do anything with the maven-dependency-plugin. So it pretty much ignores both these plugins.

like image 851
developer747 Avatar asked Nov 09 '22 15:11

developer747


1 Answers

I put the Spring Boot plugin after copy-dependencies and work fine!

<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

Notes: I clean Maven repository to work!

like image 168
Wendel Avatar answered Nov 14 '22 23:11

Wendel