我試圖執行一個JAR,它具有在JAR lib文件夾下複製的所有依賴關係。但是當我嘗試執行JAR命令行我得到以下錯誤執行jar命令行時沒有發現類錯誤
at com.abc<clinit>(abc.java:33)Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
這裏是我的JAR結構:
abc.jar ---的lib \所有依賴庫 --- COM \ ABC --- META-INF
,這裏是我的pom.xml
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
<mainClass>com.main.class</mainClass>
<classpathPrefix>./lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>