How can you configure profiles in Spring Boot to optimize configuration loading during testing?

  • Use spring.profiles.active property in application.properties file.
  • Use @Profile annotation in test classes.
  • Profiles cannot be optimized for testing.
  • Set spring.profiles.default in application.yml.
In Spring Boot, you can optimize configuration loading during testing by using the @Profile annotation in test classes. This allows you to specify which profiles should be active during testing, overriding the application's default profile. Option (1) is not the preferred way for testing. Option (4) is incorrect as it is used to set the default profile, not for testing purposes. Option (3) is incorrect; profiles can indeed be optimized for testing.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *