简体   繁体   中英

How to add JAR file to an existing WAR file web-inf/lib folder?

My setup is the following:

  • I have a war file that is not under my control (I can only pull it as dependency) which is a Spring Boot web application
  • I have a jar file that I would like to add to web-inf/lib folder so that the war file sees it on its classpath

So far I was deploying the war file to my local Tomcat and added the jar to the lib folder of the Tomcat installation. I would like to switch to a single executable war file so that I can run it via command line and not using separate Tomcat instance.

How can I achieve my goal using Maven?

You can give theoverlays feature of the maven-war-plugin a try but I'm unsure, if web-inf/lib is used by spring boot standalone executables

Robert's suggestion was correct, I would like to summarize what exactly I had to do:

  1. Use maven-war-plugin with an overlay pointing to the war dependency
  2. Set up the plugin correctly:

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.0</version> <configuration> <recompressZippedFiles>false</recompressZippedFiles> <archive> <manifestFile>src/main/resources/MANIFEST.MF</manifestFile> <compress>false</compress> </archive> <failOnMissingWebXml>false</failOnMissingWebXml>... </build>

I had to explicitly copy the manifest file (it was ignored) and disable jar compression.

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