In a Spring Boot test, how can you override the properties defined in the application.properties file?

  • Create a new application-test.properties file.
  • Use @TestPropertySource annotation to load custom properties.
  • Modify application.properties directly in the test code.
  • Properties cannot be overridden in Spring Boot tests.
In Spring Boot tests, you can override properties defined in application.properties by using the @TestPropertySource annotation to load custom properties. Option (1) is incorrect as it's not a standard practice. Option (3) is incorrect because modifying application.properties directly in test code is not recommended. Option (4) is incorrect; properties can be overridden.
Add your answer
Loading...

Leave a comment

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