Quick revision
The short answer
Expect several practical problems: Spring Boot's executable jar runs from the class path through its own launcher, so module path support for the fat jar is limited and we would need a different packaging; Spring, Hibernate and Jackson need opens on every package with beans, entities and DTOs; and many dependencies are automatic modules or contain split packages. The gains for an application are mainly encapsulation checks, and the footprint gain comes from jlink, which we can use for the JDK without the module path. For most Spring services the cost outweighs the benefit; libraries benefit more from module descriptors.
What to remember
In this answer, we saw that moving a Spring Boot service to the module path runs into the executable jar's class path launcher, opens directives for every package that Spring, Hibernate and Jackson reflect on, automatic modules and split packages among the dependencies, and extra build complexity. The gains are mainly encapsulation checks, and the footprint benefit comes from jlink, which works for the JDK without the module path. For most Spring services the cost outweighs the benefit; Spring Modulith or ArchUnit provide internal boundaries, and module descriptors are better invested in shared libraries.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Expect several practical problems: Spring Boot's executable jar runs from the class path through its own launcher, so module path support for the fat jar is limited and we would need a different packaging; Spring, Hibernate and Jackson need opens on every package with beans, entities and DTOs; and many dependencies are automatic modules or contain split packages. The gains for an application are mainly encapsulation checks, and the footprint gain comes from jlink, which we can use for the JDK without the module path. For most Spring services the cost outweighs the benefit; libraries benefit more from module descriptors.
Why this question is asked
Moving to the module path sounds like a modernisation, and the teammate's motivation is usually good: stronger encapsulation, a smaller runtime, being a proper modern Java application. But Spring Boot applications are built around reflection, classpath scanning and a special packaging format, and those meet the module system at awkward angles. Interviewers ask this to see whether we can predict the real issues and weigh them against the gains honestly. In this answer, we will recap how a Boot application runs today, go through the issues of packaging, reflection and dependencies, look at what we would actually gain, and finish with a recommendation and better alternatives.
1A Quick Recap: How a Spring Boot Jar Runs
A Spring Boot executable jar is not an ordinary jar. Our compiled classes sit under BOOT-INF/classes, every dependency sits as a complete nested jar under BOOT-INF/lib, and the manifest's Main-Class is Spring Boot's launcher, not our application. When we run java -jar app.jar, the launcher creates a class loader that can read the nested jars and then calls our main method.
Everything loaded this way lives in the unnamed module, the module system's name for class path code. So even if we add a module-info.java to the project, the fat jar ignores it in production: nothing is enforced. To really run on the module path, we would extract the jar into a directory of plain jars and launch with java --module-path, which changes our packaging, our Dockerfile and our deployment, and moves us away from the format Boot's tooling is built around.
2Issue 1: Reflection Needs opens Everywhere
Spring creates beans by reflection, injects fields and calls constructors, generates CGLIB proxy subclasses for @Configuration classes and @Transactional beans, and binds @ConfigurationProperties. Hibernate reads and writes private fields of entities. Jackson reflects on DTOs. On the module path, each of these needs deep reflective access, so every package containing such classes must be opened to the right framework modules.
Notice that missing an opens is not a compile error. It fails at run time, often only when the specific bean or entity is first used, which is precisely the kind of late failure the module system was supposed to prevent. Many teams end up declaring the whole thing as an open module, which works but gives up run-time encapsulation, the main thing the move was meant to gain. Module names of the Spring and Hibernate jars come from their Automatic-Module-Name entries, so check your versions.
3Issue 2: Dependencies That Are Not Ready
A typical Spring Boot service has well over a hundred jars on its class path. Spring's own jars carry stable Automatic-Module-Name entries but no full descriptors, so they are automatic modules, and so are many other libraries. Automatic modules work, but they read everything and export everything, so they add no encapsulation, and a jar without even a manifest name gets a name derived from its file name, which can change between versions or be invalid.
Worse are split packages. Some older dependencies put classes into the same package from different jars, for example two jars that both contain javax.annotation classes. The class path merges them silently, but the module path refuses to start until one is excluded or replaced. Finding and fixing these in a large dependency tree, and keeping them fixed as dependencies change, is ongoing work.
| Issue | Why it happens | Cost |
|---|---|---|
| Fat jar ignores module-info | Nested jars load in the unnamed module | New packaging and launch command |
| opens for every framework package | Spring, Hibernate, Jackson reflect deeply | Run-time failures when one is missing |
| Automatic modules | Most dependencies have no descriptor | Little encapsulation gained |
| Split packages | Old jars share package names | Exclusions, replacements, ongoing checks |
| Tests and tooling | Tests patched into the module, plug-ins | Build complexity for every developer |
4What We Would Gain
The main gain for an application is encapsulation checks: the compiler and JVM stop code in one package from using another module's internals. In a single Spring Boot service, though, most of the code is in one module anyway, so the boundaries that matter, between features or layers inside the service, are not module boundaries at all.
The other often-cited gain is a smaller footprint through jlink, the tool that builds a custom runtime with only the JDK modules an application needs. But jlink's main benefit for a Spring service, a runtime containing only the needed JDK modules, does not require the application to be modular. We can run jdeps on the application jars to find the JDK modules they use, link a slim runtime with jlink, and run the unchanged fat jar on it from the class path. Linking the application's own modules into the image needs every dependency to be a real named module, which is exactly what a Spring service lacks.
5Recommendation and Better Alternatives
For most Spring Boot services, the cost outweighs the benefit, so I would recommend against the move and offer the teammate the goals by cheaper routes. For internal structure, Spring Modulith treats each top-level package as an application module, verifies that modules use only each other's public API, and fails a test when a boundary is crossed; ArchUnit rules do the same for any layering we choose. For footprint and startup, a jlink runtime with only the needed JDK modules, plus class data sharing or the newer AOT cache, help without touching packaging.
Where module descriptors do pay off is in libraries: a shared library with a clear API benefits from a descriptor, or at least an Automatic-Module-Name, because its consumers get a stable name and enforced boundaries. If the teammate's interest is in the module system, that is a great place to apply it.
6Follow-up questions
Could Spring Boot ever run well on the module path?
Parts of it work today with an extracted layout and an open module, and support may improve, but frameworks built on reflection and scanning will always need extensive opens. Check your Boot version's documentation for what is supported before planning a migration.
Does GraalVM native image need the module path?
No. Spring Boot's native image support works with class path applications. Native images address startup time and memory far more than the module path would.
Is there any risk in simply adding a module-info that the fat jar ignores?
It gives a false sense of safety: the descriptor compiles, but nothing enforces it in production, and tests may run differently from production if the build puts code on the module path during testing. If we want enforced boundaries, Modulith or ArchUnit tests are enforced on every build.
7Conclusion
In this answer, we saw that moving a Spring Boot service to the module path runs into the executable jar's class path launcher, opens directives for every package that Spring, Hibernate and Jackson reflect on, automatic modules and split packages among the dependencies, and extra build complexity. The gains are mainly encapsulation checks, and the footprint benefit comes from jlink, which works for the JDK without the module path. For most Spring services the cost outweighs the benefit; Spring Modulith or ArchUnit provide internal boundaries, and module descriptors are better invested in shared libraries.
Open with
I would expect three kinds of problems. First, packaging. A Spring Boot executable jar keeps dependencies as nested jars and starts through Boot's own launcher, so everything runs in the unnamed module on the class path, and a module-info in the project is simply ignored in production.
Then, if they want more
To really use the module path we would extract the jar and launch with --module-path, which changes our build and deployment. Second, reflection.
Spring creates beans and proxies, Hibernate reads private entity fields and Jackson reflects on DTOs, so every such package needs an opens to the right framework modules, and a missing one is a run-time InaccessibleObjectException, not a compile error. Many teams end up with an open module, which gives away most of the encapsulation. Third, dependencies.
Most libraries, including Spring itself, are automatic modules without full descriptors, and some old jars have split packages, which the module path refuses to start with. The gains are mainly encapsulation checks, and the footprint win comes from jlink, which I can already use to build a slim JDK runtime for a class path application.
So for most Spring services I would say it is not worth it. For internal boundaries I would use Spring Modulith or ArchUnit, and I would invest in module descriptors for our shared libraries, where they help consumers.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A Spring Boot service runs fine on the class path. A teammate wants to move it to the...": https://scrivio-interview-library.netlify.app/java/modules/bf9681ee0e/