New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support application images with jlink #24889
Comments
@nipafx Have you tried using Maven's shade plugin to build the jar and then pointing |
Thanks for the quick reply, I will try that. I assume there's a reason, why Spring Boot doesn't just shade. Ignoring the module stuff, are there any complications I should expect with this approach? A quick Google search shows a few hits, but no official documentation. If you have an authoritative source for this, it would be greatly appreciated. 😃 |
There's a little bit in the reference documentation about some limitations of shading.
Note the |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
So this seems to work:
That's from the article by @nipafx |
I'm working on a small Spring Boot app and would like to create a self-contained application image with jlink.
What I tried
I tried several different approaches, but all of them failed.
Proper
module-info.java
My first try was to create my own
module-info.java
, but that gets moved into the fat JAR's root without further changes. That means it still lists the Spring modules as dependencies, but since they're now included in the JAR, they won't be found on any module path and thus jlink refuses to create the image.There are hacky ways around that (creating empty JARs with the right module names), but I suspect this would lead to the same problems as the next approach.
Using Moditect on fat JAR
With Moditect, I can inject a module declaration into the fat JAR. That's actually pretty easy because there are no external dependencies.
Unfortunately, jlink refuses to create the image because of the
BOOT-INF
folder:(I expect the approach above would fail at this step as well even if the problem with the module descriptor could be solved.)
Using Moditext on all JARs
I considered configuring Spring Boot to not create a fat JAR. My goal was to then use Moditect to create a module descriptor for all (transitive) dependencies of the app and thus use jlink on all of them. This may work, but due to the sheer number of dependencies and my (possibly faulty) impression that I need to configure the declaration for all of them. That's a lot of work.
Conclusion
It seems that there's no (good) way to create an application image that contains a Spring Boot app. That's a shame because that's a pretty nifty feature. It would be nice if Spring Boot offered at least one path to application image heaven. 😁
The text was updated successfully, but these errors were encountered: