如何在使用 maven 构建的战争中包含系统依赖项 [英] How to include system dependencies in war built using maven
问题描述
我在互联网上搜索了很长时间,但我无法弄清楚如何配置 maven-war 插件或类似的东西,以便系统依赖项包含在内置战争 (WEB-INF/lib文件夹)
I've searched on internet for quite some time and I'm unable to figure out how to configure the maven-war plugin or something alike so that the system dependencies are included in the built-war (WEB-INF/lib folder)
在 jar-build 的情况下,我使用 maven 依赖插件:
I use the maven dependency plugin in case of a jar-build as :
<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>
但我无法理解在战争构建的情况下要做什么.我试过使用 maven-war 插件,但它没有在构建中包含系统依赖项.
but I'm unable to understand what is to be done in case of a war build. I've tried using the maven-war plugin, but it's not including system-dependencies in the build.
[更新]
我有以下类型的依赖:
<dependency>
<groupId>LoginRadius</groupId>
<artifactId>LoginRadius</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}libLoginRadius-1.0.jar</systemPath>
</dependency>
在我的 POM 中,并且在构建战争时这些依赖项不包含在 WEB-INF/lib 中.
in my POM and these dependencies are not included in WEB-INF/lib when the war is build.
推荐答案
让我试着总结一下我尝试过的选项:
Let me try to summarise the options I tried :
<packagingIncludes>${java.home}/lib/jfxrt.jar</packagingIncludes>
这不行!此外,只有 jar 名称,排除其他所有内容,因此如果您愿意尝试,请尝试
This doesn't work! Also, only having the jar name, excludes everything else, so if you are willing to try then try
<packagingIncludes>${java.home}/lib/jfxrt.jar,**/*</packagingIncludes>
Jatin 的回答似乎有点复杂,我再次尝试通过 POM &再次找出 WEB-INF POM 中提到的系统 jar 的确切位置.
Jatin's answer seemed a bit complex and I tried going through the POM again & again to figure out where exactly were the system jars mentioned to be included in WEB-INF POM.
无论如何,我最终使用了这个解决方案,它起初不起作用,但经过一段时间和一些更正后起作用了:
Anyways, I ended up using this solution, which wasn't working at first but after some time and some corrections worked :
我使用以下命令在本地存储库中安装了 jar:
I installed the jar in my local repository using the below command :
mvn install:install-file -Dfile="C:UsershpDocumentsNetBeansProjectsTwitterAndLoginRadiusMavenlibLoginRadius-1.0.jar" -DgroupId=LoginRadius -DartifactId=LoginRadius -Dversion=1.0 -Dpackaging=jar`
运行上述命令后,我将POM中的依赖改为
After running the above command, I changed the dependency in POM to
<dependency>
<groupId>LoginRadius</groupId>
<artifactId>LoginRadius</artifactId>
<!--<scope>system</scope>-->
<version>1.0</version>
<!--<systemPath>${basedir}libLoginRadius-1.0.jar</systemPath>-->
</dependency>
注意 - 请参阅我已评论系统范围 &系统路径.
NOTE - See I've commented the system scope & systemPath.
现在构建战争,在 WEB-INF/lib 中包含这个 LoginRadius-1.0.jar
Building the war now, includes this LoginRadius-1.0.jar in WEB-INF/lib
这篇关于如何在使用 maven 构建的战争中包含系统依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!