Posts

Showing posts with the label Spring Data JDBC

Spring Boot - Testing Spring Data JDBC application with @DataJdbcTest - Example

Image
In this section, we will learn how to test Repository layer components with @DataJdbcTest in Spring Boot application. 1.  @ DataJdbcTest Instead of bootstrapping the entire application context for every test, @DataJdbcTest allows us to initialize the Spring application context with only those beans needed to test Spring Data JDBC-based components. It will auto-configure JdbcTemplate and if an embedded database is available on the classpath, @ DataJdbcTest   will autoconfigure one for testing purposes. By default, tests annotated with @ DataJdbcTest   are transactional and roll back at the end of each test, means we do not need to clean up saved or modified table data after each test. Regular @Component , @Service or @Controller beans are not scanned when using this annotation.  This approach not only speeds up the testing process but also ensures a focused and efficient testing environment. This approach is also known as "slicing" the application context. Find the sample c

Spring Data JDBC + Azure Database for MySQL - Build REST CRUD APIs

Image
In this section, we will learn how to build REST CRUD APIs with  Spring Boot ,  Spring Data JDBC  and  Microsoft  Azure Database for MySQL. A little bit of Background Azure Database for MySQL Single Server Azure Database for MySQL Single Server is a fully managed database service designed for minimal customization. The single server platform is designed to handle most of the database management functions such as patching, backups, high availability, and security with minimal user configuration and control. The architecture is optimised for built-in high availability with 99.99% availability in a single availability zone. It supports the community version of MySQL 5.6 (retired), 5.7 and 8.0. The service is generally available today in a wide variety of  Azure regions . More Info -  Overview - Azure Database for MySQL Single Server | Microsoft Learn Spring Boot Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can "just run".