Maven exec插件 - 如何包含“系统”类路径? [英] Maven exec plugin- how to include "system" classpath?

查看:84
本文介绍了Maven exec插件 - 如何包含“系统”类路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目使用system范围来指定项目的 WEB-INF / lib 目录中包含的jar文件。此工件不在任何maven存储库中,因此我必须将其作为项目的一部分包含在内。我这样做有以下几点:

I have a project that uses "system" scope to specify a jar file included in my project's WEB-INF/lib dir. This artifact is not in any of the maven repositories, so I must include it as part of my project. I do so with the following:

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>MySpecialLib</artifactId>
        <version>1.2</version>
        <scope>system</scope>
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/MySpecialLib-1.2.jar</systemPath>
    </dependency>

这对大多数事情都有用。

This has worked great for most things.

但是现在我正在尝试在命令行上运行一些代码(在我的webapp之外,通过 main()我添加的方法)和 mvn exec:java 无法解析MySpecialLib中的代码,因为它没有包含在运行时类路径中。

But now I'm trying to run some code on the command line (outside of my webapp, via a main() method I have added) and mvn exec:java can't resolve code in MySpecialLib because it's not included in the "runtime" classpath.

我该如何:


  • 将MySpecialLib添加到运行时类路径


  • 告诉 mvn exec:java 还要使用系统类路径?

  • tell mvn exec:java to also use the system classpath ?

I已经尝试过 mvn exec:java -Dexec.classpathScope = system ,但这会使 runtime 上的所有内容失效。

I've tried mvn exec:java -Dexec.classpathScope=system, but that leaves off everything that's on runtime.

推荐答案

使用'compile'范围运行maven exec插件 - mvn exec:java -Dexec.classpathScope =编译。这将包括系统范围的依赖项。

Use 'compile' scope to run maven exec plugin - mvn exec:java -Dexec.classpathScope=compile. This will include system-scoped dependencies.

这篇关于Maven exec插件 - 如何包含“系统”类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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