简体   繁体   中英

How to link external Spring Boot JAR in manifest (NoClassDefFoundError)

I'll try to boil my issue down into a basic external JAR linking question, which I have not been able to find an example/answer for. I have 2 JARs, a.jar and b.jar, in the same directory. The MANIFEST.MF of a.jar contains: Class-Path: b.jar .

Essentially, I want to run a.jar that contains minimal application-level classes, but links to a large external b.jar with all other necessary classes. But running the command java -jar a.jar results in: Exception in thread "main" java.lang.NoClassDefFoundError: com/example/MainApp .

Not sure if it's relevant, but b.jar is actually a Spring Boot JAR which contains the expected classes (eg com/example/MainApp.class ) in BOOT-INF/classes . The MANIFEST.MF of b.jar contains: Spring-Boot-Classes: BOOT-INF/classes/ .

I want to know if there's a simple way to achieve this? Let me know if any more details are needed to diagnose the issue.

Update: I copied the com/example/MainApp.class file to the base directory in b.jar, and the class was found! But I want to keep the original files in place. So I suppose that rephrases the question: how do you specify where classes are located inside the JAR?

您是否尝试过类似“ classpath:path / to / jar / b.jar”之类的路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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