Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Populate correctly the environment in BootstrapCodeGenerator #992

Closed
sdeleuze opened this issue Aug 23, 2021 · 1 comment
Closed

Populate correctly the environment in BootstrapCodeGenerator #992

sdeleuze opened this issue Aug 23, 2021 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@sdeleuze
Copy link
Contributor

As discussed with @snicoll, the javamail sample is broken because the environnement is not properly propagated to BootstrapCodeGeneratorRunner, for example based on the application.properties of the project. In javamail sample case, MailSenderPropertiesConfiguration is discarded at build time because no spring.mail.host is defined even if specified in the application.properties project file.

Like proposed in #989, we should probably use a file instead of command line arguments to pass those contextual information to BootstrapCodeGeneratorRunner.

@sdeleuze sdeleuze added this to the 0.11.0 milestone Aug 23, 2021
@bclozel bclozel changed the title Populate correctly the environment in BootstrapCodeGeneratorRunner Populate correctly the environment in BootstrapCodeGenerator Aug 25, 2021
bclozel added a commit that referenced this issue Aug 26, 2021
Prior to this commit, the `ContextBootstrapContributor` would prepare an
empty `Environment` and only apply some defaults to it. This lead to
several sample applications failing as properties provided by the
application (in `application.properties`) would not be considered.

As a consequence, all `@ConditionalOnProperty` on `*.enabled`
configuration keys would be discarded at build time if not enabled by
default in Spring Boot.

This commit loads a minimal infrastructure and prepares an `Environment`
that partially loads the application configuration at build time.

There are many limitations with this current approach:

* this doesn't support many customizations on the `SpringApplication`
* this doesn't load `Bootstrapper` so will fail with configuration
  trying to resolve properties using `Bootstrappers`, like Eureka.

Fixes gh-992
@bclozel
Copy link
Contributor

bclozel commented Aug 26, 2021

Fixed with 02a7abc

@bclozel bclozel closed this as completed Aug 26, 2021
snicoll pushed a commit that referenced this issue Sep 28, 2021
Prior to this commit, the `ContextBootstrapContributor` would prepare an
empty `Environment` and only apply some defaults to it. This lead to
several sample applications failing as properties provided by the
application (in `application.properties`) would not be considered.

As a consequence, all `@ConditionalOnProperty` on `*.enabled`
configuration keys would be discarded at build time if not enabled by
default in Spring Boot.

This commit loads a minimal infrastructure and prepares an `Environment`
that partially loads the application configuration at build time.

There are many limitations with this current approach:

* this doesn't support many customizations on the `SpringApplication`
* this doesn't load `Bootstrapper` so will fail with configuration
  trying to resolve properties using `Bootstrappers`, like Eureka.

Fixes gh-992
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Development

No branches or pull requests

2 participants