この質問は以前にも聞かれたと思います。私はすでに述べたように他のオプションを試しましたが、成功しませんでした:(
BackGround: Mavenを使用してすべての依存関係を持つjarをパッケージ化します。
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly:package</id>
<phase>package</phase>
<goals>
<!-- Work around for http://jira.codehaus.org/browse/MASSEMBLY-97
as the goal should be attached. -->
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.Application</mainClass>
</manifest>
<manifestEntries>
<Class-Path>config/</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
classPath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java" />
<classpathentry kind="src" path="src/main/resources" />
<classpathentry exported="true" kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7" />
</classpath>
エクスポートしたjarを使用して実行している場合
java -cp Scheduler-0.0.1-SNAPSHOT-exe.jar com.Application
私は例外を取得しています
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/c
ontext/support/ClassPathXmlApplicationContext
at com.Application.main(Application.java:13)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support
.ClassPathXmlApplicationContext
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
これについて何かアイデアはありますか?すべての依存jarにSpringバージョン3.0.6を使用しています。
Gendafulに感謝します