如何在使用maven构建的战争中包括系统依赖关系 [英] How to include system dependencies in war built using maven

查看:114
本文介绍了如何在使用maven构建的战争中包括系统依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上搜索了很长一段时间,我无法弄清楚如何配置maven-war插件或类似的东西,以便系统依赖关系被包含在内置的战争(WEB-INF / lib文件夹)



我使用maven依赖插件,如果是jar-build:

 <插件> 
< artifactId> maven-dependency-plugin< / artifactId>
<执行>
< execution>
< phase> install< / phase>
< goals>
< goal> copy-dependencies< / goal>
< / goals>
< configuration>
< outputDirectory> $ {project.build.directory} / lib< / outputDirectory>
< / configuration>
< / execution>
< / executions>
< / plugin>

但是我无法理解在战争建立时要做什么。我试过使用maven-war插件,但它不包括构建中的系统依赖关系。



[更新]



我有不同的类型:

 < dependency> 
< groupId> LoginRadius< / groupId>
< artifactId> LoginRadius< / artifactId>
< scope> system< / scope>
< version> 1.0< / version>
< systemPath> $ {basedir} \lib\LoginRadius-1.0.jar< / systemPath>
< / dependency>在我的POM中,

,这些依赖关系在构建战争时不包含在WEB-INF / lib中。

解决方案

让我尝试总结我尝试的选项:



< packagingIncludes> $ {java.home} /lib/jfxrt.jar</packagingIncludes>



不工作!此外,只有具有jar名称,排除其他所有内容,所以如果您愿意尝试尝试



< packagingIncludes> $ {java。 home} /lib/jfxrt.jar,** / *< / packageIncludes>



Jatin的回答似乎有点复杂,通过POM再次再次确定在哪里提到的系统jar被包括在WEB-INF POM中。



无论如何,我最终使用了这个解决方案,首先,但经过一段时间后,一些修正工作:



使用以下命令在我的本地存储库中安装jar:



mvn install:install-file -Dfile =C:\Users\hp\Documents\NetBeansProjects\TwitterAndLoginRadiusMaven\ lib\LoginRadius-1.0.jar-DgroupId = LoginRadius -DartifactId = LoginRadius -Dversion = 1.0 -Dpackaging = jar



运行以上命令,我将POM中的依赖关系更改为

 < dependency> 
< groupId> LoginRadius< / groupId>
< artifactId> LoginRadius< / artifactId>
<! - < scope>系统< / scope> - >
< version> 1.0< / version>
<! - < systemPath> $ {basedir} \lib\LoginRadius-1.0.jar< / systemPath> - >
< / dependency>

注意 - 我已经评论过系统范围& Systempath下。



现在构建战争,在WEB-INF / lib中包含此LoginRadius-1.0.jar


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)

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>

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.

[UPDATE]

I'm having depedencies of type :

<dependency>
    <groupId>LoginRadius</groupId>
    <artifactId>LoginRadius</artifactId>
    <scope>system</scope>
    <version>1.0</version>
    <systemPath>${basedir}\lib\LoginRadius-1.0.jar</systemPath>
</dependency>

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>

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'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 :

installed the jar in my local repository using the below command :

mvn install:install-file -Dfile="C:\Users\hp\Documents\NetBeansProjects\TwitterAndLoginRadiusMaven\lib\LoginRadius-1.0.jar" -DgroupId=LoginRadius -DartifactId=LoginRadius -Dversion=1.0 -Dpackaging=jar

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}\lib\LoginRadius-1.0.jar</systemPath>-->
        </dependency>

NOTE - See I've commented the system scope & systemPath.

Building the war now, includes this LoginRadius-1.0.jar in WEB-INF/lib

这篇关于如何在使用maven构建的战争中包括系统依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆