Skip to main content

Posts

Showing posts from November, 2024

Dynamically Loading YAML Files in Spring Boot with Java

In modern applications, configuration plays a crucial role in maintaining flexibility and modularity. Often, we need to load properties from multiple YAML files, organized across nested directories, to ensure scalability and modular configuration. In this blog, we’ll explore how to dynamically load all YAML files from a specific directory structure and merge their properties into a single configuration object. Use Case Imagine we have a configuration directory like this: src/main/resources ├── application.yml ├── configs │   ├── environment │   │   ├── dev.yml │   │   ├── qa.yml │   ├── features │   │   ├── feature1.yml │   │   ├── feature2.yml We want to load all YAML files under the configs directory (including subdirectories), merge them, and make the properties available for use in our Spring Boot application. Implementation 1. Dynamic YAML Loader We will create a utility class to dy...

Generate Java POJOs from JSON Schemas with jsonschema2pojo

  Steps to Generate POJOs Add Dependency Add the jsonschema2pojo plugin to your pom.xml :   <plugin>     <groupId>org.jsonschema2pojo</groupId>     <artifactId>jsonschema2pojo-maven-plugin</artifactId>     <version>1.1.2</version>     <executions>         <execution>             <goals>                 <goal>generate</goal>             </goals>         </execution>     </executions>     <configuration>         <sourceDirectory>${basedir}/src/main/resources/schemas</sourceDirectory>         <targetPackage>com.example.pojo</targetPackage>     </configuration> </plugin> Prepare JSON Schemas Save your s...

Performance Testing a Spring Boot Application with Gatling

In this blog, we’ll explore using Gatling , a powerful load-testing tool, to test a simple Spring Boot application. We'll set up a performance test for a sample REST API endpoint, demonstrate step-by-step how Gatling integrates with the project, and configure a scenario similar to the example discussed earlier. What is Gatling? Gatling is a highly performant open-source load-testing tool. It helps simulate high-traffic scenarios for your APIs, ensuring your application can handle the expected (or unexpected) load efficiently. 1. Setting Up the Spring Boot Project We'll create a Spring Boot REST API with a simple /search endpoint that accepts query parameters: query and category . @RestController @RequestMapping("/api") public class SearchController {     @GetMapping("/search")     public ResponseEntity<String> search(             @RequestParam String query,             @RequestParam String category)...

Top 10 Flavorful Combinations Using Ajwain, Ginger, Tea, and Black Pepper for a Bold, Invigorating Drink

When it comes to exploring unique flavors, there’s a lot of magic in mixing spices and herbs that are both warming and aromatic. Ajwain (carom seeds), ginger, tea, and black pepper are each powerful in their own right but even better together. Whether you’re looking for a soothing, immunity-boosting drink or a bold experiment in flavor, these combinations bring a range of tastes and benefits. Let’s dive into the top 10 best combinations of these ingredients, ranked for flavor and experience. 1. Ginger + Black Pepper + Tea This is a classic combination, bringing together ginger's warmth, black pepper’s spiciness, and the depth of tea. This drink is not only satisfying but also great for boosting immunity and relieving congestion. How to Make It : Boil sliced ginger and a pinch of black pepper in water. Add tea leaves, simmer for a minute, strain, and serve. Add honey for sweetness if you like. 2. Ajwain + Ginger + Tea Combining the earthy pungency of ajwain with fresh ginger and tea...