Skip to content

Instantly share code, notes, and snippets.

@rajeevshukla
Created January 17, 2023 19:32
Show Gist options
  • Save rajeevshukla/3cb42011fa395d98c91d8cea66321d7e to your computer and use it in GitHub Desktop.
Save rajeevshukla/3cb42011fa395d98c91d8cea66321d7e to your computer and use it in GitHub Desktop.
Environment post processor
@Configuration
public class DevProfileEnvironmentPostProcessor implements EnvironmentPostProcessor {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
if (environment.acceptsProfiles("dev")) {
Map<String, Object> devProperties = new HashMap<>();
devProperties.put("server.port", 8080);
devProperties.put("logging.level.org.springframework.web", "DEBUG");
devProperties.put("logging.level.com.example.application", "TRACE");
environment.getPropertySources().addFirst(new MapPropertySource("devProperties", devProperties));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment