Skip to content

Add Spring Boot auto-configuration and a starter artifact #714

Description

@bbottema

Why

The existing spring-module provides SimpleJavaMailSpringSupport, but applications still have to add it explicitly with @Import. The module already knows how to read the Spring Environment and create SimpleJavaMailConfig, SimpleJavaMail and a default Mailer, so Spring Boot can reasonably discover that setup automatically.

At the moment the module compiles against Spring Framework 5.3.39 and uses Spring Boot 2.7.18 for tests and configuration metadata. A 10.0.0 design must deliberately decide how Boot 2 and Boot 3 are supported instead of accidentally tying the whole Spring module to one generation.

Proposed direction

Provide Boot auto-configuration that:

  • creates an immutable SimpleJavaMailConfig from the Spring Environment;
  • creates a SimpleJavaMail factory and default Mailer;
  • backs off when the application provides its own beans;
  • picks up an application-provided OAuth2AccessTokenProvider;
  • closes only the Mailer it created;
  • keeps application profiles, placeholders and Spring property-source precedence authoritative.

Publish a thin starter artifact so Boot users can add one dependency. Keep spring-module and manual @Import(SimpleJavaMailSpringSupport.class) available for plain Spring and for applications that want explicit control.

Compatibility decision

Investigate whether one auto-configuration artifact can support both Boot 2.7 and Boot 3.x cleanly. If not, use clearly named generation-specific artifacts rather than reflection or runtime version checks scattered through the code.

The core Simple Java Mail libraries target Java 11 in 10.0.0. Boot 3 applications already require a newer JDK, but that should not force non-Boot or Boot 2 users off Java 11.

Tests and documentation

Cover default creation, user bean overrides, isolated application contexts, property precedence, OAuth2 provider injection and shutdown. Boot tests should use the normal auto-configuration discovery mechanism rather than naming the configuration class directly.

The website should show the starter dependency and zero-annotation setup while retaining the existing plain-Spring instructions.

Related history

#63 introduced Spring Environment support and the current manual @Import(SimpleJavaMailSpringSupport.class) setup. #475 added Spring Boot configuration metadata and already raised a dedicated Boot module as an option. #466 made Mailer closeable so Spring can clean up its connection-pool resources during application shutdown.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions