How can you configure multiple data sources in a Spring Boot application?
- By creating separate @Configuration classes for each data source.
- By using multiple instances of the @DataSource annotation.
- Data sources can't be configured in Spring Boot applications.
- Using only the application.properties or application.yml file.
To configure multiple data sources in a Spring Boot application, you should create separate @Configuration classes for each data source. These classes should define DataSource beans with distinct properties for each data source. This approach allows you to specify different database configurations for different parts of your application. Using only the properties file or annotations like @DataSource won't provide the required flexibility.
Loading...
Related Quiz
- How can you customize Ribbon’s load-balancing strategy in a Spring Cloud application?
- In the Spring Boot project structure, the _____ directory is recommended for placing application's static content.
- To customize the response body of a global exception handler method in Spring Boot, the method should return an object of type _____.
- You need to implement a feature in a Spring Boot application where data is streamed from the server to the client as soon as it’s available. How would you implement this feature using reactive programming principles?
- A Spring Boot application is facing frequent OutOfMemoryErrors. Describe the steps you would take to diagnose the root cause and mitigate this issue.