繁体   English   中英

向maven exec添加一个jar:java classpath

[英]add a jar to maven exec:java classpath

我有一个批处理文件,它使用maven运行java类,它依赖于tools.jar(来自JDK)。
例如:
mvn -f。\\ pom.xml -e exec:java -Dfile.encoding =“UTF-8”-Dexec.mainClass = MyClass -Dexec.args =“%1%2%3%4%5%6%7% 8%9“-Dexec.classpathScope =运行时
我的程序使用JDK中的tools.jar,我在maven中添加了一个指向它的系统依赖。
由于exec:java目标不包含系统依赖项,我想手动从命令行添加依赖项。
虽然我预计它是微不足道的,但我可以找到办法。 任何帮助将不胜感激。
谢谢,
阿夫纳

从我在maven exec插件中读到的内容,它允许您将可执行的依赖项配置为插件依赖项。

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <includeProjectDependencies>false</includeProjectDependencies>
          <includePluginDependencies>true</includePluginDependencies>
          <executableDependency>
            <groupId>com.example.myproject</groupId>
            <artifactId>mylib</artifactId>
          </executableDependency>
          <mainClass>com.example.Main</mainClass>
        </configuration>
        <dependencies>
          <dependency>
                <groupId>sun.jdk</groupId>
                <artifactId>tools</artifactId>
                <version>1.5.0</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
          </dependency>
        </dependencies>
      </plugin>

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM