简体   繁体   中英

How to package spring boot project with multiple JAR dependencies?

I have a spring boot project that has a few local jar files dependencies like

  • mssql-jdbc-6.2.1.jre8.jar
  • internal-commons.jar
  • internal-db.jar
  • etc.

How do I package the project into a WAR file? Thanks in advance

You can use existing libraries to achieve this. If you use maven , you can use the maven-dependency-plugin

For example, in your pom.xml file, add the following to your dependencies:

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

And then, use it as a plugin in your pom.xml :

            <plugin>
                <!-- http://jonathangraham.github.io/2016/01/05/Local_Jar_Dependency_With_Maven -->
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The entire process is explained here in more detail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM