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.
Loading...
Related Quiz
- Imagine you are starting a new Spring Boot project where you need to support both web applications and RESTful APIs. How would you set up the project to accommodate both requirements effectively?
- How can you implement token enhancement to include custom claims in an OAuth2 JWT token generated by a Spring Boot application?
- In Spring Boot, the _____ annotation is used to denote a reactive programming model in a controller.
- In Spring Boot, to map HTTP GET requests to a specific handler method, the _____ annotation is used.
- How can you profile a production Spring Boot application without affecting its performance significantly?