🍃🎓 SPRING CERTIFICATION QUESTION: How do you configure a DataSource in Spring? Which bean is beneficial for development/test databases?
🍃🎓 SPRING CERTIFICATION QUESTION: How do you configure a DataSource in Spring? Which bean is beneficial for development/test databases?
Answer:
DataSource is a factory to obtain database connections. There're several ways to create DataSource beans in a Spring application:
- using JNDI lookup
- using JDBC DataSource vendors
- using test-purpose DataSource implementations provided by Spring Framework (e.g. DriverManagerDataSource, SingleConnectionDataSource, embedded Datasource created via EmbeddedDatabaseBuilder class).
Preferable development DataSource is a pooled-Datasource obtained by JNDI lookup. For testing purposes, embedded Datasource EmbeddedDatabase is sometimes sufficient.
Examples of mentioned terms:
SampleDataSourceConfiguration - basic example for configuring production/development Datasource s.(in the attachment below)👇👇👇
#spring #certificationquestion #vcp
Configuring a DataSource👉 https://www.baeldung.com/spring-boot-configure-data-source-programmatic