0

When I use Maven to package the Spring Boot project, I do not want all dependencies to be packaged into the final JAR package. I want to start the JAR with -djava.ext.dirs referencing all dependent packages. How to write Maven pom.xml?

I use configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>

    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
        </execution>
    </executions>
</plugin>

It has a problem that it cannot find the main function when using java-jar main.jar

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Does this answer your question? [How can I create an executable JAR with dependencies using Maven?](https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) – Christophe Quintard Sep 05 '22 at 05:56
  • 1
    The Java extensions directory feature was deprecated in Java 8 and removed in Java 9. It is not something you should use (and in versions that do support it, your use case is not a valid use of the Java extensions directory feature). – Mark Rotteveel Sep 05 '22 at 08:08

0 Answers0