![](/img/trans.png)
[英]Failed to collect dependencies at org.apache.maven.plugins:maven-dependency-plugin:jar:2.10
[英]Running a java jar with eclipse swt dependencies with maven-dependency-plugin
我正在制作一個eclipse插件,我也想使其在命令行下工作。 通常,通常的問題是在命令行中遇到Eclipse依賴項:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
現在,我知道有一個關於這個問題的日食常見問題解答,但是這里有點不同。 我正在使用Maven與maven-dependency-plugin進行構建,以將其他項目所需的jar添加到此jar作為依賴項:
<build>
<plugins>
<plugin>
<!-- Copy non-Eclipse plugins to target/dependency so that may be referenced
for runtime use. -->
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- seems the line below is needed otherwise every second run the
copy-dependencies fails , link to bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=393978 -->
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我的清單文件中的依賴項如下所示:
Rsrc-Class-Path: ./
lib/jcommon-1.0.23.jar
lib/jfreechart-1.0.19.jar
lib/jfreechart-1.0.19-swt.jar
lib/jfreechart-1.0.19-experimental.jar
lib/swt.jar
target/dependency/my.first.package.jar
target/dependency/my.second.package.jar
Class-Path: .
Rsrc-Main-Class: my.package.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Bundle-ClassPath: .,
lib/jcommon-1.0.23.jar,
lib/jfreechart-1.0.19-experimental.jar,
lib/jfreechart-1.0.19-swt.jar,
lib/jfreechart-1.0.19.jar,
lib/swt.jar
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
my.first.package;visibility:=reexport,
my.second.package;visibility:=reexport,
ca.odell.glazedlists,
org.eclipse.nebula.widgets.nattable.core,
org.eclipse.core.resources,
org.eclipse.swt
如您所見,我在項目內的lib中添加了一個swt.jar,並在那里引用它,以使我的所有依賴項都在jar中。
當我嘗試在命令行中運行swt.jar時,仍然出現上述錯誤。
我想念什么?
如果要使Eclipse插件命令行友好,最好的辦法是讓該插件還定義一個Eclipse應用程序,然后可以從命令行調用它: https : //wiki.eclipse.org/FAQ_How_do_I_create_an_application%3F
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.