Skip to content

Split auto-configuration out into several smaller, more focused modules #37599

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

Open
rupert-madden-abbott opened this issue Sep 27, 2023 · 1 comment
Labels
status: pending-design-work Needs design work before any code can be developed type: enhancement A general enhancement

Comments

@rupert-madden-abbott
Copy link
Contributor

rupert-madden-abbott commented Sep 27, 2023

At the moment, various templating libraries, are integrated with Spring in the following way:

  • they have auto-configuration inside spring-boot-autoconfigure which integrates them as renderers for HTTP responses
  • they activate based on the presence of that templating library on the classpath
  • they have a starter that adds the necessary libraries onto the classpath
  • they have a "disabled" property that allows an application to disable the HTTP integration

The problem is that templating libraries can be pulled in for reasons other than for templating HTTP views. For example, I imagine a very common use case would be for templating emails. When this is done, one must remember to also set the disabled property or else warnings can be shown at startup and unexpected problems can occur like this one.

One way I can see that this behavior could be improved is by moving the auto-configuration for these libraries out of spring-boot-autoconfigure and into the starters instead. So spring-boot-starter-mustache would also pull in the mustache auto-configuration. Perhaps the starter should also make it more clear that it is supposed to be for web templating only e.g. spring-boot-starter-web-mustache. If this were done then:

  • The disabled properties would be come redundant and could be removed
  • Users who wanted to use these libraries in the web tier would just need to pull in the starter, as they are likely already doing
  • Users who do not want to use these libraries in the web tier would not use the starter, and would either use the underlying library directly, or via some other third party starter library

This also means that if the templating library arrives on the classpath as a transitive dependency, the application author no longer needs to explicitly disable the auto-configuration integrating it into the web tier.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 27, 2023
@philwebb
Copy link
Member

We've actually discussed this idea many times on the team but not yet had a good opportunity to take it on. Ideally we'd like to keep the starters as they and instead create more granular auto-configuration jars on which the starters could depend on.

Unfortunately, it's quite a big job to split up auto-configuration.

@philwebb philwebb added for: team-meeting An issue we'd like to discuss as a team to make progress type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Sep 27, 2023
@philwebb philwebb added this to the General Backlog milestone Oct 4, 2023
@philwebb philwebb added the status: pending-design-work Needs design work before any code can be developed label Oct 4, 2023
@wilkinsona wilkinsona changed the title Make it harder to unintentionally enable web templating Split auto-configuration out into several smaller, more focused modules Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending-design-work Needs design work before any code can be developed type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants