Skip to content

Spring Boot Java 9+ modularity #13799

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

Closed
m31collision opened this issue Jul 17, 2018 · 3 comments
Closed

Spring Boot Java 9+ modularity #13799

m31collision opened this issue Jul 17, 2018 · 3 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@m31collision
Copy link

I want to build java 9+ modular (Jigsaw) application using Spring Boot. Currently it is not possible: suppose we have application which consist of main and web modules. I'm expecting that

  • main module will depend on spring-boot + spring-core
  • web module will depend on spring-web and will be able to see and use main module and its dependencies

But it will not work because Spring Boot has hard coded dependency on spring-web, so class loading will fail in such hierarchy. I will have to move Spring Web dependency from web module to main module but such modularity makes no sense for application.

Do you have plans to modularize Spring Boot and Spring projects in general?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 17, 2018
@wilkinsona
Copy link
Member

Do you have plans to modularize Spring Boot

We don't have any plans to modularise Spring Boot any further as we've yet to see a compelling use-case for doing so. Given that your application is going to be deployed as a single unit, what benefits do you see from splitting it into separate Jigsaw modules? I'm particularly interested in any benefits that can't be achieved with separate packages, package-private visibility and, perhaps, separate Maven/Gradle projects.

Our recommendation is that, when using Java 9+, you take advantage of the JDK's modularity while using the classpath (rather than the module path) via java -jar to run your application.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jul 18, 2018
@m31collision
Copy link
Author

I think this is not so useless features:

  1. it will be possible to use jlink to create reduced JRE which does not work with non-explicit modules
  2. export only those packages that should be used by Spring users (as it happened with famous sun.misc.Unsafe)
  3. as a result of restricted visibility of packages and dependencies, this makes possible to hold dependency of different versions in different module layers - it is very common case when you need to include some libraries to your application which has colliding transitive dependencies (in my case, I need to use Elasticsearch which uses Jackson JSON library, and I would like to use convenient Spring framework, but it also use Jackson JSON library but different version)
  4. applications built on modules can be deployed with only required modules without wasting disk space...
  5. ...and can use hot reload of modules without restarting

There may be more benefits that I don't see, but of course, modularizing may cost very expensive.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 18, 2018
@wilkinsona
Copy link
Member

Thanks.

In our experimentation, the benefits of JLink have been rather underwhelming. Exploratory work being done with GraalVM suggests that it's a far more promising approach, both in terms of binary size and startup performance. There's a Spring Framework issue tracking support for Graal native images.

The problem you describe with Elasticsearch is, as I understand it, why the dropped support for embedding Elasticsearch. That is to say, I don't think believe Jigsaw to be the answer to their classpath problems.

I'm going to close this one as, at this time, we don't plan to do anything more in this area. We can perhaps revisit this in the future if the ecosystem starts to move towards Jigsaw and Spring Framework moves beyond automatic modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants