简体   繁体   English

如何将 JAR 文件添加到现有的 WAR 文件 web-inf/lib 文件夹中?

[英]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我有一个不受我控制的war文件(我只能将其作为依赖项提取),它是一个 Spring Boot web 应用程序
  • 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我有一个jar文件,我想将它添加到web-inf/lib文件夹中,以便 war 文件在其类路径中看到它

So far I was deploying the war file to my local Tomcat and added the jar to the lib folder of the Tomcat installation.到目前为止,我正在将 war 文件部署到我的本地 Tomcat 并将 jar 添加到 Tomcat 安装的 lib 文件夹中。 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.我想切换到一个可执行的war文件,这样我就可以通过命令行运行它,而不是使用单独的 Tomcat 实例。

How can I achieve my goal using Maven?如何使用 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您可以尝试使用 maven-war-plugin 的覆盖功能,但我不确定 spring 引导独立可执行文件是否使用 web-inf/lib

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使用 maven-war-plugin 与指向战争依赖的覆盖
  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.我必须明确复制清单文件(它被忽略)并禁用 jar 压缩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Jar文件添加到WEB-INF / lib - Adding Jar File to WEB-INF/lib 将JAR文件添加到web-inf / lib文件夹中,而不将其包含在pom.xml中 - Add JAR-File to web-inf/lib folder without including it in pom.xml 在JBOSS 7中,war文件可以访问ear / lib而非Web-inf / lib中的jar文件 - In JBOSS 7 can war file access a jar file located in ear/lib instead of web-inf/lib 如何在战争的WEB-INF文件夹中包含属性文件 - How to include a property file in WEB-INF folder of war Web组件WEB-INF LIB应该包含在war文件中的哪个jar - what jar's should Web Component WEB-INF LIB should contain in a war file Maven:在war / WEB-INF / lib中找不到本地依赖文件 - Maven: Local dependecy file not found into war/WEB-INF/lib 在`WEB-INF / lib`文件夹中找不到jar文件的解决方案,也没有在`src / main / resources`文件夹中找到? - Solution for a jar file not findable in the `WEB-INF/lib` folder nor `src/main/resources` folder? 自动将新的Jar文件复制到Tomcat项目WEB-INF / lib文件夹中 - Automatically copy new Jar file to Tomcat project WEB-INF/lib folder 如何从远程服务器为位于apache-tomcat WEB-INF / lib文件夹下的jar文件制作下载URL? - How to make a download url for the jar file located under apache-tomcat WEB-INF/lib folder from remote server? 如何将 JAR 文件添加到 Eclipse 中的 web-inf/lib 文件夹? - How can I add JAR files to the web-inf/lib folder in Eclipse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM