[英]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.