Skip to content
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

Allow the configuration of active profiles in SpringApplication.Augmented #36660

Closed
odrotbohm opened this issue Aug 1, 2023 · 4 comments
Closed
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@odrotbohm
Copy link
Member

The new support for running local application instances supported by Testcontainers based services suggests the creation of a secondary application bootstrap class in src/test/java pointing to the original one but including additional configuration. The proposed way to bootstrap such a class is through SpringApplication.from(…) returning an Augmented instance.

As that class is becoming the central bootstrap mechanism for local development, it would be nice to be able to make sure the application is always run with a dedicated profile. Especially, without having to explicitly pass it into the application either via command line arguments or a dedicated launch configuration in the IDE. Something along the lines of:

SpringApplication.from(Application::main)
  .withProfilesEnabled(…)
  .run(args);
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 1, 2023
@philwebb philwebb changed the title Allow SpringApplication.Augmented to get active profiles configured Allow the configuration of active profiles in SpringApplication.Augmented Aug 2, 2023
@mhalbritter mhalbritter added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 8, 2023
@mhalbritter mhalbritter added this to the 3.x milestone Aug 8, 2023
@aldex32
Copy link

aldex32 commented Apr 5, 2024

Hello,
it would be very useful feature in my view.

@tschuehly
Copy link

This would indeed be very helpful!

@jurri-cz
Copy link

jurri-cz commented Aug 15, 2024

Stumbling upon this, I found a possible workaround to OP by adding a program argument --spring.profiles.active=some-profile to the call of Augmented. Something like this:

    public static void main(String... args) {
        String[] augmentedArgs = Stream.concat(
                Stream.of("--spring.profiles.active=local-run"),
                Stream.of(args)
        ).toArray(String[]::new);

        SpringApplication
                .from(Application::main)
                .run(augmentedArgs);
    }

@mhalbritter mhalbritter self-assigned this Sep 16, 2024
@mhalbritter mhalbritter modified the milestones: 3.x, 3.4.0-M3 Sep 16, 2024
@odrotbohm
Copy link
Member Author

Thanks, Moritz! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

6 participants