<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Farai Matsika on Medium]]></title>
        <description><![CDATA[Stories by Farai Matsika on Medium]]></description>
        <link>https://medium.com/@fasoft90?source=rss-eb1d3dafb0ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b6rnor5rNCCJ9Iqjss_PSQ.png</url>
            <title>Stories by Farai Matsika on Medium</title>
            <link>https://medium.com/@fasoft90?source=rss-eb1d3dafb0ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:47:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fasoft90/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Connecting Your Spring Boot Application to MySQL]]></title>
            <link>https://medium.com/@fasoft90/connecting-your-spring-boot-application-to-mysql-26ee3595bfc6?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/26ee3595bfc6</guid>
            <category><![CDATA[jpa]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[springboot-3]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 18:04:06 GMT</pubDate>
            <atom:updated>2025-11-20T18:04:06.594Z</atom:updated>
            <content:encoded><![CDATA[<p>Databases are the backbone of backend applications. Today, we’ll connect a Spring Boot application to a <strong>MySQL database via XAMPP</strong>, configure it using application.yml, and define a simple entity with <strong>Lombok</strong> to reduce boilerplate code. You’ll also see how Hibernate automatically creates tables for you.</p><h3>1. Installing MySQL via XAMPP</h3><ol><li>Download and install XAMPP from <a href="https://www.apachefriends.org/index.html">https://www.apachefriends.org/index.html</a>.</li><li>Open the <strong>XAMPP Control Panel</strong> and start <strong>Apache</strong> and <strong>MySQL</strong>.</li><li>Open <strong>phpMyAdmin</strong> at <a href="http://localhost/phpmyadmin.">http://localhost/phpmyadmin.</a></li></ol><h3>2. Adding Dependencies</h3><p>Add the following dependencies in your pom.xml:</p><pre>&lt;!-- Spring Data JPA --&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br><br>&lt;!-- MySQL Connector --&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;mysql&lt;/groupId&gt;<br>&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;<br>&lt;scope&gt;runtime&lt;/scope&gt;<br>&lt;/dependency&gt;<br><br>&lt;!-- Lombok --&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>&lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>&lt;version&gt;1.18.28&lt;/version&gt;<br>&lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><h3>3. Configuring Database Connection with application.yml</h3><pre>spring:<br>  datasource:<br>    url: jdbc:mysql://localhost:3306/student_db?useSSL=false&amp;serverTimezone=UTC<br>    username: root<br>    password:  # leave blank if no password<br>    driver-class-name: com.mysql.cj.jdbc.Driver<br><br>  jpa:<br>    hibernate:<br>      ddl-auto: update<br>    show-sql: true<br>    properties:<br>      hibernate:<br>        dialect: org.hibernate.dialect.MySQL8Dialect</pre><ul><li>ddl-auto: update → Hibernate automatically creates or updates tables based on your entities.</li><li>show-sql: true → Displays SQL statements in the console for debugging.</li></ul><h3>4. Creating a Student Entity with Lombok</h3><pre>import jakarta.persistence.Entity;<br>  import jakarta.persistence.GeneratedValue;<br>  import jakarta.persistence.GenerationType;<br>  import jakarta.persistence.Id;<br>  import lombok.AllArgsConstructor;<br>  import lombok.Data;<br>  import lombok.NoArgsConstructor;<br>  <br>  @Entity<br>  @Data<br>  @NoArgsConstructor<br>  @AllArgsConstructor<br>  public class Student {<br><br>  @Id<br>  @GeneratedValue(strategy = GenerationType.IDENTITY)<br>  private Long id;<br><br>  private String name;<br>  private String email;<br>}</pre><h3>5. Creating the Repository</h3><pre>import org.springframework.data.jpa.repository.JpaRepository;<br>  <br>  public interface StudentRepository extends JpaRepository&lt;Student, Long&gt; {<br>}</pre><h3>6. Testing the Connection</h3><pre>import org.springframework.boot.CommandLineRunner;<br>  import org.springframework.stereotype.Component;<br>  import org.springframework.beans.factory.annotation.Autowired;<br>  <br>  @Component<br>  public class DataLoader implements CommandLineRunner {<br><br>  @Autowired<br>  private StudentRepository studentRepository;<br><br>  @Override<br>  public void run(String... args) throws Exception {<br>  studentRepository.save(new Student(null, &quot;Alice&quot;, &quot;alice@example.com&quot;));<br>  studentRepository.save(new Student(null, &quot;Bob&quot;, &quot;bob@example.com&quot;));<br>  System.out.println(&quot;Students saved successfully!&quot;);<br>  }<br>}</pre><ul><li>Start your Spring Boot app.</li><li>Open <strong>phpMyAdmin</strong> → student_db → You should see a <strong>student</strong> table automatically created with columns: id, name, and email.</li><li>The console will display the SQL statements executed by Hibernate.</li></ul><h3>7. Assignment</h3><ul><li>Connect these entities to your <strong>REST API endpoints</strong> (from the previous Swagger lesson) to perform CRUD operations.</li><li>Explore relationships between entities (One-to-Many, Many-to-Many).</li><li>Experiment with different ddl-auto options (create, update, validate) to understand table management.</li></ul><p>Using <strong>YAML configuration</strong> and <strong>Lombok</strong> simplifies setup and code readability. By connecting your Spring Boot app to MySQL via XAMPP, you now have a solid foundation for building backend applications with persistent data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26ee3595bfc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Swagger Documentation for Your REST API in Spring Boot]]></title>
            <link>https://medium.com/@fasoft90/setting-up-swagger-documentation-for-your-rest-api-in-spring-boot-15fda85ac55c?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/15fda85ac55c</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[swagger-ui]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 17:50:07 GMT</pubDate>
            <atom:updated>2025-11-20T17:51:22.052Z</atom:updated>
            <content:encoded><![CDATA[<p>Swagger (via Springdoc OpenAPI) is an essential tool for documenting and testing your REST APIs. It provides an interactive interface where you and your team can explore endpoints, try out requests, and see responses in real-time. Today, we’ll focus on <strong>adding Swagger to an existing Spring Boot project</strong> and creating a simple dummy controller to test it.</p><ol><li>Adding Swagger Dependency</li></ol><p>Add the Springdoc OpenAPI dependency to your pom.xml</p><pre>&lt;dependency&gt;<br>&lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>&lt;artifactId&gt;springdoc-openapi-ui&lt;/artifactId&gt;<br>&lt;version&gt;1.8.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Springdoc OpenAPI works automatically with minimal setup. Just run your application, and Swagger UI will be available.</p><h3>2. Configuring Swagger</h3><p>Springdoc OpenAPI works automatically with minimal setup. Just run your application, and Swagger UI will be available.</p><p><strong>Access Swagger UI:</strong></p><p><a href="http://localhost:8080/swagger-ui.html">http://localhost:8080/swagger-ui.html</a></p><p>Optional: Customize your Swagger documentation with a configuration class:</p><pre>@Configuration<br>  public class SwaggerConfig {<br>  @Bean<br>  public OpenAPI customOpenAPI() {<br>  return new OpenAPI()<br>  .info(new Info()<br>  .title(&quot;Student API&quot;)<br>  .version(&quot;1.0&quot;)<br>  .description(&quot;API documentation for a student management system&quot;));<br>  }<br>}</pre><h3>3. Creating a Dummy REST Controller</h3><p>Now, let’s define some endpoints so Swagger can document them:</p><pre>@RestController<br>  @RequestMapping(&quot;/students&quot;)<br>  public class StudentController {<br><br>  @GetMapping<br>  public List&lt;String&gt; getAll() {<br>  return List.of(&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;);<br>  }<br><br>  @PostMapping<br>  public String create(@RequestBody String student) {<br>return &quot;Created student: &quot; + student;<br>  }<br><br>  @PutMapping(&quot;/{id}&quot;)<br>  public String update(@PathVariable int id, @RequestBody String student) {<br>  return &quot;Updated student &quot; + id + &quot; to &quot; + student;<br>}<br><br>  @DeleteMapping(&quot;/{id}&quot;)<br>  public String delete(@PathVariable int id) {<br>return &quot;Deleted student with ID: &quot; + id;<br>}<br>}</pre><ul><li>Swagger will automatically detect these endpoints and generate the API documentation.</li><li>You can send requests directly from Swagger UI and see responses instantly.</li><li>Explore the Swagger interface and try sending GET/POST/PUT/DELETE requests.</li><li>Observe how request and response schemas are automatically displayed.</li><li>Think about how you’d document models when using entities (like a Student class) in a real application.</li></ul><p>By completing this lesson, you now have a <strong>fully documented REST API with Swagger</strong> and a dummy controller to practice with. This prepares you for the next step: <strong>connecting your API to a database and implementing full CRUD operations</strong>, which we will cover in the upcoming session.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15fda85ac55c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot Basics—Creating Your First Application]]></title>
            <link>https://medium.com/@fasoft90/spring-boot-basics-creating-your-first-application-6d56472d157c?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d56472d157c</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 09:04:13 GMT</pubDate>
            <atom:updated>2025-11-16T09:04:13.801Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to Spring Boot!</p><p>Spring Boot is one of the most powerful tools in the Java ecosystem. It allows developers to create <strong>production-ready applications</strong> with minimal configuration. Instead of writing hundreds of lines of setup code, Spring Boot gives you <strong>default configurations</strong>, <strong>embedded servers</strong>, and <strong>fast development tools</strong>.</p><p>In today’s lecture, we will cover:</p><ul><li>How to create a Spring Boot project</li><li>Understanding the project structure</li><li>How to build your first REST API endpoint</li><li>How to run your application locally</li></ul><p>By the end of this lesson, every student will have a working Spring Boot application running on <strong>localhost:8080</strong>.</p><p>Before we begin, ensure:</p><ul><li>You have <strong>IntelliJ IDEA</strong> installed (Community or Ultimate)</li><li>You have <strong>Java 17</strong> installed</li><li>Maven is installed (or IntelliJ will auto-manage it)</li></ul><h3>Step 1: Create a New Spring Boot Project in IntelliJ</h3><h3>Steps:</h3><ol><li>Open <strong>IntelliJ IDEA</strong></li><li>Click <strong>New Project</strong></li><li>On the left panel, select <strong>Spring Initializr</strong></li></ol><ul><li>(This option uses Initializr inside IntelliJ — NOT the website)</li></ul><ol><li>Choose:</li></ol><ul><li><strong>Project SDK:</strong> Java 17</li><li><strong>Language:</strong> Java</li><li><strong>Build System:</strong> Maven</li></ul><p>Click <strong>Next</strong></p><p>Step 2: Add Spring Boot Dependencies</p><p>On the dependencies screen, select:</p><ul><li><strong>Spring Web</strong></li><li><strong>Lombok</strong></li></ul><p>Then click <strong>Next</strong></p><h3>Step 3: Set Project Metadata</h3><p>Fill in:</p><ul><li><strong>Group:</strong> com.example</li><li><strong>Artifact:</strong> demo</li><li><strong>Name:</strong> demo</li><li><strong>Package name:</strong> com.example.demo</li></ul><p>Click <strong>Finish</strong></p><p>IntelliJ will now download packages and generate the project for you.</p><h3>Step 4: Understanding the Project Structure</h3><p>Once IntelliJ finishes loading, your project structure will look like this:</p><pre>src<br> └── main<br>     ├── java<br>     │    └── com.example.demo<br>     │         └── DemoApplication.java<br>     └── resources<br>          ├── application.properties<br>          └── static/<br>pom.xml</pre><h3>Key Files Explained:</h3><h3>✔ DemoApplication.java</h3><p>This is the entry point.<br> It contains:</p><pre>@SpringBootApplication<br>public class DemoApplication {<br>    public static void main(String[] args) {<br>        SpringApplication.run(DemoApplication.class, args);<br>    }<br>}</pre><h3>✔ resources/</h3><ul><li>application.properties → for configurations</li><li>static/ → for web content (if needed)</li></ul><h3>✔ pom.xml</h3><p>Manages your dependencies and project build.</p><h3>Step 5: Create Your First REST API</h3><p>Inside com.example.demo, create a class:</p><p><strong>HelloController.java</strong></p><p>Add:</p><pre>@RestController<br>public class HelloController {<br><br>    @GetMapping(&quot;/hello&quot;)<br>    public String sayHello() {<br>        return &quot;Hello from Spring Boot!&quot;;<br>    }<br>}</pre><h3>Step 6: Run the Spring Boot Application</h3><h3>Run using IntelliJ</h3><p>Click the <strong>green play button</strong> next to DemoApplication.java</p><h3>Step 7: Test the Endpoint</h3><p>Open any browser and visit:</p><pre>http://localhost:8080/hello</pre><p>you will see below</p><pre>Hello from Spring Boot!</pre><p>We have learnt how to:</p><ul><li>Initialize a Spring Boot project <strong>inside IntelliJ</strong></li><li>Add dependencies</li><li>Understand the project structure</li><li>Create and run a REST API</li><li>Test an endpoint on localhost</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d56472d157c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your First Java Program—Understanding the Basics]]></title>
            <link>https://medium.com/@fasoft90/your-first-java-program-understanding-the-basics-76c0883764e4?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/76c0883764e4</guid>
            <category><![CDATA[intellij]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 08:35:00 GMT</pubDate>
            <atom:updated>2025-11-16T08:35:00.651Z</atom:updated>
            <content:encoded><![CDATA[<p>Every developer remembers their first “Hello World.”<br> It’s more than tradition—it’s the first step toward understanding how Java works.</p><p>In this article, students write their first Java program and learn the building blocks of the language.</p><h3>Step 1: Create a New Java Project</h3><ul><li>Open IntelliJ IDEA → “New Project”</li><li>Choose: <em>Java → Maven/Gradle (optional)</em></li><li>Select JDK version</li><li>Create a simple class file: Main.java</li></ul><pre>public class Main {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Hello World&quot;);<br>    }<br>}</pre><h3>Understanding the Code</h3><p>✔ class Main → A Java class<br> ✔ public static void main → Entry point of every Java program<br> ✔ System.out.println → Prints text to the console</p><h3>Step 3: Run the Program</h3><p>Using IntelliJ:<br> Click the green run button while opening the Main.java class → Output appears in console.</p><p>After this session, students understand how Java programs are structured and how code flows during execution. This fundamental knowledge becomes essential for object-oriented programming and later, Spring Boot development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76c0883764e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Java & Developer Setup (Beginner-Friendly Guide)]]></title>
            <link>https://medium.com/@fasoft90/introduction-to-java-developer-setup-beginner-friendly-guide-1d9aeed336a3?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d9aeed336a3</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[springboot-3]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 08:28:48 GMT</pubDate>
            <atom:updated>2025-11-16T08:28:48.823Z</atom:updated>
            <content:encoded><![CDATA[<p>Java remains one of the most powerful and widely-used programming languages in the world. Whether you’re building enterprise systems, Android apps, or backend services, Java provides the performance, reliability, and structure needed for production-grade software.</p><p>In this article, we walk through the very first steps every new Java developer must take—installing Java, setting up your IDE, and preparing your machine for development.</p><h3>🛠 Step 1: Install Java (JDK)</h3><p>To write and run Java code, you need the <strong>Java Development Kit (JDK)</strong>.<br> The recommended version for beginners is <strong>Java 17</strong>, a Long-Term Support (LTS) release.</p><ul><li>Download from: <em>Oracle JDK</em> or <em>OpenJDK builds such as Temurin.</em></li><li>or click this link <a href="https://www.oracle.com/java/technologies/downloads/#license-lightbox">https://www.oracle.com/java/technologies/downloads/#license-lightbox</a></li><li>After installation, confirm with:</li></ul><pre>java -version<br>javac -version</pre><h3>Step 2: Install IntelliJ IDEA</h3><p>IntelliJ IDEA is the most developer-friendly IDE for Java and Spring Boot.</p><ul><li>Install IntelliJ IDEA Ultimate and opt for a free trial.</li><li>Enable plugins: Lombok, Maven, Docker (optional)</li></ul><p>click link below to dowlnoad<br><a href="https://www.jetbrains.com/idea/download/download-thanks.html?platform=windows">Thank you for downloading IntelliJ IDEA!</a></p><p>Your machine is now fully prepared for Java development. This setup lays the foundation for everything else you will learn — from object-oriented programming to enterprise-grade Spring Boot applications.</p><h3>Step 3: Install Maven on Windows (Step-by-Step)</h3><h3>1. Download Maven</h3><p>Go to the official Maven downloads page:<br> 👉 <em>Search on Google: “Apache Maven download”</em><br> Download the <strong>Binary zip archive</strong> (e.g., apache-maven-3.9.x-bin.zip).</p><h3>2. Extract the ZIP</h3><ul><li>Right-click → <strong>Extract All</strong></li><li>Move the folder to (<strong><em>if you don&#39;t have the below structure, you can create the folders</em></strong>):<br> C:\Program Files\Apache\Maven</li></ul><p>Your Maven directory will look like:<br> C:\Program Files\Apache\Maven\apache-maven-3.9.x</p><h3>3. Set Environment Variables</h3><h4>a. Add M2_HOME</h4><ol><li>Press <strong>Windows Key</strong> → search <strong>“Environment Variables”</strong></li><li>Click <strong>Environment Variables</strong></li><li>Under <em>System Variables</em> → Click <strong>New</strong></li></ol><ul><li><strong>Variable name:</strong> M2_HOME</li><li><strong>Variable value:</strong><br> C:\Program Files\Apache\Maven\apache-maven-3.9.x</li></ul><h4>b. Add MAVEN_HOME (optional but common)</h4><ul><li>Name: MAVEN_HOME</li><li>Value: same as M2_HOME</li></ul><h4>c. Add Maven to PATH</h4><p>Still in System Variables:</p><ul><li>Select Path → <strong>Edit</strong></li><li>Click <strong>New</strong></li><li>Add:<br> C:\Program Files\Apache\Maven\apache-maven-3.9.x\bin</li></ul><p>Click <strong>OK</strong> on all windows.</p><h3>4. Verify Installation</h3><p>Open <strong>Command Prompt</strong> and run:</p><pre>mvn -version</pre><p>You should see somehting like :</p><pre>Apache Maven 3.9.x<br>Java version: 17</pre><p>DONE!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d9aeed336a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplify Your Microservices Architecture with an API Gateway and Swagger Aggregator]]></title>
            <link>https://medium.com/@fasoft90/simplify-your-microservices-architecture-with-an-api-gateway-and-swagger-aggregator-9cffa2233348?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cffa2233348</guid>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 08:29:11 GMT</pubDate>
            <atom:updated>2025-09-11T08:29:11.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iW0plIgHnPYZBLayPDCcww.png" /></figure><h3>The Problem: API Documentation Overload</h3><p>In today’s microservices architecture, it’s common to have multiple services, each with its own API documentation. This often leads to:</p><ul><li>Frontend developers juggling multiple Swagger UIs and ports</li><li>Security concerns with exposing multiple endpoints</li><li>Inconsistent API documentation experience</li><li>CORS and authentication headaches</li></ul><h3>The Solution: API Gateway with Swagger Aggregation</h3><p>By implementing an API Gateway with Swagger aggregation, you can:</p><ol><li>Centralize all your API documentation in one place</li><li>Simplify frontend integration</li><li>Enhance security by exposing a single entry point</li><li>Improve developer experience with unified documentation</li></ol><h3>Implementation Walkthrough</h3><h3>1. Setting Up the API Gateway Configs</h3><pre>server:<br>  port: 8447<br><br>eureka:<br>  instance:<br>    prefer-ip-address: true<br>  client:<br>    registerWithEureka: true<br>    fetchRegistry: true<br>    service-url:<br>      defaultZone: http://localhost:8761/eureka/<br><br>spring:<br>  application:<br>    name: api-gateway<br>  cloud:<br>    gateway:<br>      default-filters:<br>        - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin<br>      globalcors:<br>        corsConfigurations:<br>          &#39;[/**]&#39;:<br>            allowedOrigins: &quot;*&quot;<br>            allowedMethods: &quot;*&quot;<br>            allowedHeaders: &quot;*&quot;<br>      routes:<br>        - id: auth-server<br>          uri: lb://AUTH-SERVER<br>          predicates:<br>            - Path=/auth/**<br>          filters:<br>            - RewritePath=/auth/(?&lt;segment&gt;.*), /${segment}<br><br>        - id: booking-service<br>          uri: lb://BOOKING-SERVICE<br>          predicates:<br>            - Path=/booking-service/**<br>          filters:<br>            - RewritePath=/booking-service/(?&lt;segment&gt;.*), /${segment}<br><br>        - id: notification-service<br>          uri: lb://NOTIFICATION-SERVICE<br>          predicates:<br>            - Path=/notification-service/**<br>          filters:<br>            - RewritePath=/notification-service/(?&lt;segment&gt;.*), /${segment}<br><br>        - id: products-service<br>          uri: lb://PRODUCTS-SERVICE<br>          predicates:<br>            - Path=/products-service/**<br>          filters:<br>            - RewritePath=/products-service/(?&lt;segment&gt;.*), /${segment}<br><br>springdoc:<br>  api-docs:<br>    enabled: true<br>  swagger-ui:<br>    enabled: true<br>    urls:<br>      - name: AUTH-SERVER<br>        url: /auth/v3/api-docs<br>      - name: BOOKING-SERVICE<br>        url: /booking-service/api-docs<br>      - name: NOTIFICATION-SERVICE<br>        url: /notification-service/v3/api-docs<br>      - name: PRODUCTS-SERVICE<br>        url: /products-service/api-docs</pre><h3>3. Adding the Swagger Dependency</h3><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>    &lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;<br>    &lt;version&gt;2.2.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>    &lt;artifactId&gt;springdoc-openapi-starter-webflux-api&lt;/artifactId&gt;<br>    &lt;version&gt;2.5.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>    &lt;artifactId&gt;springdoc-openapi-starter-webflux-ui&lt;/artifactId&gt;<br>    &lt;version&gt;2.5.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><h3>3. Adding Swagger Configuration Class</h3><pre>package com.fasoft_projects.api_gateway;<br><br>import io.swagger.v3.oas.models.OpenAPI;<br>import io.swagger.v3.oas.models.info.Contact;<br>import io.swagger.v3.oas.models.info.Info;<br>import io.swagger.v3.oas.models.info.License;<br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br><br>@Configuration<br>public class SwaggerConfigurations {<br><br>    @Bean<br>    public OpenAPI myOpenAPI() {<br><br>        Contact contact = new Contact();<br>        contact.setEmail(&quot;developers@fasoft.co.zw&quot;);<br>        contact.setName(&quot;Fasoft Engineering Team&quot;);<br>        contact.setUrl(&quot;https://www.fasoft.co.zw/#/&quot;);<br><br>        License mitLicense = new License().name(&quot;MIT License&quot;).url(https://medium.com/&quot;https://choosealicense.com/licenses/mit/&quot;);<br><br>        Info info = new Info()<br>                .title(&quot;API Gateway&quot;)<br>                .version(&quot;1.0&quot;)<br>                .contact(contact)<br>                .description(&quot;API Gateway Documentation for Routing and Aggregation&quot;)<br>                .termsOfService(&quot;https://www.fasoft.co.zw/#/&quot;)<br>                .license(mitLicense);<br><br>        return new OpenAPI().info(info);<br>    }<br>}</pre><h3>Key Benefits</h3><ol><li>Single Source of Truth: One URL for all your API documentation</li><li>Simplified Authentication: One token to rule them all</li><li>Better Developer Experience: No more port juggling</li><li>Easier Maintenance: Update documentation in one place</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*j993vKpVLHMEUi27Zthtfw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LNTD7naSL-7IIovazwHPaw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cffa2233348" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Being the API Blocker: How to Build Self-Documenting APIs Your Team Will Love]]></title>
            <link>https://medium.com/@fasoft90/stop-being-the-api-blocker-how-to-build-self-documenting-apis-your-team-will-love-6acd49267083?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/6acd49267083</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 17:15:05 GMT</pubDate>
            <atom:updated>2025-08-25T17:15:05.455Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*STxN_PVK9_MvFN2v" /></figure><p>Does any of this sound familiar?</p><ul><li>The Frontend team is blocked. They’re waiting for you to hop on a call to explain, for the third time, how the new endpoint works.</li><li>You’re the “hero.” The project grinds to a halt when you’re offline because you’re the only one who knows the API flow.</li><li>The handover from hell. You just spent two hours explaining your service to a new developer, but you can tell from their blank stare that nothing stuck.</li><li>The blame game. You’re called out as a blocker in the daily stand-up because the frontend team is sending the wrong JSON payload, and they swear you never told them the correct format.</li><li>The dreaded “documentation” ticket. It’s been sitting in the backlog for months, a constant source of guilt and anxiety.</li></ul><p>If you’re a backend developer, you’ve likely lived through this nightmare. It’s a common syndrome in our industry: we build powerful, complex APIs but fail at the last, crucial step — communicating how to use them. We rely on meetings, Slack messages, and outdated Confluence pages, creating chaos, frustration, and bottlenecks.</p><p>But what if there was a better way? What if your API could document itself, providing a single source of truth that’s always up-to-date, easy to understand, and professional enough to share with anyone?</p><p>In this article, I’ll walk you through how to build exactly that using Spring Boot and Swagger (OpenAPI 3). We won’t just add a few annotations; we’ll create a structured, maintainable, and scalable documentation system that will make you the most popular developer on your team.</p><h3>The Goal: From API Chaos to Clarity</h3><p>Our mission is to build a REST API that is so well-documented that it requires zero hand-holding. A frontend developer, a new team member, or even a third-party integrator should be able to look at our Swagger UI and understand everything: every endpoint, every parameter, every response code, and every data model.</p><p>Here’s how we’ll do it:</p><ol><li>Structure the API: Set up a clean Spring Boot project with controllers, services, and DTOs.</li><li>Centralize Documentation: Create a single constants file for all documentation strings to keep our code DRY and easy to update.</li><li>Annotate Everything: Systematically document our DTOs and controllers using Swagger annotations.</li><li>Configure for Professionalism: Customize the Swagger UI to include security schemes (like JWT), contact info, and licensing.</li></ol><h3>Step 1: Setting Up the Project</h3><p>Let’s start with the foundation. We need a Spring Boot project with three key dependencies in our pom.xml:</p><ol><li>spring-boot-starter-web: For building REST APIs.</li><li>springdoc-openapi-starter-webmvc-ui: The magic library that automatically generates the Swagger UI from our code.</li><li>lombok: To reduce boilerplate code in our DTOs with annotations like @Data.</li></ol><pre>&lt;!-- pom.xml --&gt;<br>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>        &lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;<br>        &lt;version&gt;2.2.0&lt;/version&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>        &lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>        &lt;optional&gt;true&lt;/optional&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><h3>Step 2: The Secret Sauce — Centralizing Documentation Strings</h3><p>This is the step that separates amateur documentation from a professional, maintainable system. Instead of hardcoding descriptions directly into annotations (which quickly becomes a nightmare to manage), we’ll define them all in one place.</p><p>Create a class called ApiConstants.java. This file will be the single source of truth for every piece of text in our documentation.</p><pre>public final class ApiConstants {<br>    // Generic Responses<br>    public static final String SUCCESS_200 = &quot;200&quot;;<br>    public static final String CREATED_201 = &quot;201&quot;;<br>    public static final String NO_CONTENT_204 = &quot;204&quot;;<br>    public static final String NOT_FOUND_404 = &quot;404&quot;;<br><br>    public static final String FOUND_DESCRIPTION = &quot;Resource found&quot;;<br>    public static final String CREATED_DESCRIPTION = &quot;Resource created successfully&quot;;<br>    public static final String UPDATED_DESCRIPTION = &quot;Resource updated successfully&quot;;<br>    public static final String DELETED_DESCRIPTION = &quot;Resource deleted successfully&quot;;<br>    public static final String NOT_FOUND_DESCRIPTION = &quot;Resource not found&quot;;<br><br>    // Product DTO Descriptions<br>    public static final String PRODUCT_ID_DESCRIPTION = &quot;Unique identifier of the Product.&quot;;<br>    public static final String PRODUCT_NAME_DESCRIPTION = &quot;Name of the Product.&quot;;<br>    // ...and so on for every DTO and controller description<br>}</pre><p>Why is this so powerful? If you need to rephrase a description or fix a typo, you only have to change it in one place, and the update will propagate everywhere. It keeps your code clean and your documentation consistent.</p><h3>Step 3: Documenting the Data Models (DTOs)</h3><p>With our constants in place, let’s document our DTOs. We use the @Schema annotation to describe each field. Notice how we reference the constants we just created.</p><pre>import io.swagger.v3.oas.annotations.media.Schema;<br>import lombok.Data;<br>import zw.co.afrosoft.swaggerauthtokenexample.util.ApiConstants;<br><br>@Data<br>public class ProductDto {<br><br>    @Schema(description = ApiConstants.PRODUCT_ID_DESCRIPTION, example = &quot;1&quot;, required = true)<br>    private Long id;<br><br>    @Schema(description = ApiConstants.PRODUCT_NAME_DESCRIPTION, example = &quot;Laptop&quot;, required = true)<br>    private String name;<br><br>    @Schema(description = ApiConstants.PRODUCT_DESCRIPTION_DESCRIPTION, example = &quot;A high-performance laptop&quot;, required = true)<br>    private String description;<br><br>    @Schema(description = ApiConstants.PRODUCT_PRICE_DESCRIPTION, example = &quot;1200.50&quot;, required = true)<br>    private double price;<br>}</pre><p>Now, anyone looking at our documentation will know exactly what each field in the ProductDto represents, its data type, and an example value.</p><h3>Step 4: Documenting the Endpoints (Controllers)</h3><p>This is where it all comes together. We’ll use a combination of annotations to describe our ProductController.</p><ul><li>@Operation: A high-level summary of what the endpoint does.</li><li>@ApiResponses: Details about possible HTTP responses (e.g., 200 OK, 404 Not Found).</li><li>@Parameter: Describes the parameters for an endpoint (e.g., a path variable).</li><li>@SecurityRequirement: Specifies that the endpoint requires authentication.</li></ul><pre><br>@RestController<br>@RequestMapping(&quot;/products&quot;)<br>@SecurityRequirement(name = &quot;authorization&quot;) // This endpoint requires a token<br>public class ProductController {<br><br>    // ... service injection<br><br>    @Operation(summary = ApiConstants.GET_PRODUCT_BY_ID_SUMMARY)<br>    @ApiResponses(value = {<br>            @ApiResponse(responseCode = ApiConstants.SUCCESS_200, description = ApiConstants.FOUND_DESCRIPTION,<br>                    content = { @Content(mediaType = &quot;application/json&quot;,<br>                            schema = @Schema(implementation = ProductDto.class)) }),<br>            @ApiResponse(responseCode = ApiConstants.NOT_FOUND_404, description = ApiConstants.NOT_FOUND_DESCRIPTION,<br>                    content = @Content)<br>    })<br>    @GetMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;ProductDto&gt; getProductById(<br>            @Parameter(description = ApiConstants.SEARCH_ID_DESCRIPTION) @PathVariable Long id) {<br>        // ... implementation<br>    }<br><br>    // ... other endpoints (GET all, POST, PUT, DELETE) are documented similarly<br>}</pre><p>Look at how clean that is! The controller code is not cluttered with long, hardcoded strings. It’s readable, maintainable, and fully documented.</p><h3>Step 5: Polishing the Final Product with Swagger Configuration</h3><p>Finally, let’s give our documentation a professional look and feel. We can create a SwaggerConfig.java file to customize the generated UI. Here, we can define our security scheme (JWT Bearer Token) and add contact and license information.</p><pre>// ... imports<br><br>@Configuration<br>public class SwaggerConfig {<br><br>    @Bean<br>    public OpenAPI customOpenAPI() {<br>        return new OpenAPI()<br>                .info(new Info()<br>                        .title(&quot;Comprehensive E-commerce API by Fasoft&quot;)<br>                        .version(&quot;1.0.0&quot;)<br>                        .contact(new Contact().name(&quot;fasoft&quot;).email(&quot;info@fasoft.co.zw&quot;))<br>                        .license(new License().name(&quot;Apache 2.0&quot;).url(https://medium.com/&quot;http://springdoc.org&quot;)))<br>                .addSecurityItem(new SecurityRequirement().addList(&quot;authorization&quot;))<br>                .components(new Components()<br>                        .addSecuritySchemes(&quot;authorization&quot;,<br>                                new SecurityScheme()<br>                                        .name(&quot;authorization&quot;)<br>                                        .type(SecurityScheme.Type.HTTP)<br>                                        .scheme(&quot;bearer&quot;)<br>                                        .bearerFormat(&quot;JWT&quot;)<br>                                        .in(SecurityScheme.In.HEADER)<br>                                        .description(&quot;JWT Authorization header using the Bearer scheme.&quot;)));<br>    }<br>}</pre><p>With this configuration, our Swagger UI will now feature a global “Authorize” button, making it easy for developers to test protected endpoints.</p><h3>The Result: Documentation That Works</h3><p>After running the application, navigate to http://localhost:8080/swagger-ui.html. You will be greeted with a beautiful, interactive, and comprehensive documentation page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*5IxUnVDoQmbcTAFqJ4FtQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*KbUGKOmOFDcApG9oqlnXZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUOY3wlwBFKCBsAz6qO14Q.png" /></figure><p>We have solved all our initial problems:</p><ul><li>No more blocking: The frontend team can see every model, endpoint, and example on their own.</li><li>No more “heroes”: The documentation is the single source of truth, not a person.</li><li>Handovers are a breeze: Just send the Swagger UI link.</li><li>Fewer errors: Clear examples and schemas mean fewer mistakes.</li><li>Documentation is done! And it will stay up-to-date as long as you maintain the annotations alongside your code.</li></ul><h3>Bonus: Exporting to PDF</h3><p>Need formal, offline documentation? The springdoc library exposes the OpenAPI specification as a JSON file at /v3/api-docs. You can use online tools or CLI utilities to convert this JSON file into a professional PDF document, ready for stakeholders or formal archives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6acd49267083" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swagger + Bearer Token Authentication: No Need to Switch to Postman]]></title>
            <link>https://medium.com/@fasoft90/swagger-bearer-token-authentication-no-need-to-switch-to-postman-f6466610fcbd?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6466610fcbd</guid>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Sat, 16 Aug 2025 08:50:09 GMT</pubDate>
            <atom:updated>2025-08-16T08:50:09.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwmFt_j9cpLuzDQCpSmBGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qao0u493_qwgXgw8ieTCGQ.png" /></figure><p>A few days ago, I was with a developer who was testing his Spring Boot APIs. He had <strong>Swagger UI</strong> running but also kept Postman open at the same time.</p><p>When I asked why, his response was:<br> 👉 <em>“I use Postman because it lets me insert a token when testing secured endpoints.”</em></p><p>That was my moment to step in and show him something powerful:<br> <strong>Swagger itself can handle Bearer Token authentication.</strong><br> No need to switch between tools.</p><p>He was amazed—and that inspired me to put together a small demo project that shows how you can set this up in minutes.</p><h3>Why This Matters</h3><p>If your API uses JWT tokens (or any bearer token system), you want your API docs (Swagger UI) to:</p><ul><li>Display an <strong>“Authorize”</strong> button at the top.</li><li>Let you paste your token once.</li><li>Apply that token automatically to all secured endpoints.</li></ul><p>This means:<br> ✅ One interface for documentation <em>and</em> testing.<br> ✅ Less context switching between tools.<br> ✅ Easier onboarding for new developers.</p><h3><strong>Step 1: Setting Up Swagger with Bearer Token Authentication</strong></h3><p>In a Spring Boot project with <strong>springdoc-openapi</strong>, add the following configuration.</p><pre>@Configuration<br>public class SwaggerConfig {<br><br>    @Bean<br>    public OpenAPI customOpenAPI() {<br>        return new OpenAPI()<br>                .info(new Info().title(&quot;Swagger Auth Token Example API&quot;)<br>                        .description(&quot;Demo for centralized token authentication using Swagger @SecurityRequirement.&quot;)<br>                        .version(&quot;1.0.0&quot;))<br>                .addSecurityItem(new SecurityRequirement().addList(&quot;authorization&quot;))<br>                .components(new io.swagger.v3.oas.models.Components()<br>                        .addSecuritySchemes(&quot;authorization&quot;,<br>                                new SecurityScheme()<br>                                        .name(&quot;authorization&quot;)<br>                                        .type(SecurityScheme.Type.HTTP)<br>                                        .scheme(&quot;bearer&quot;)<br>                                        .bearerFormat(&quot;JWT&quot;)<br>                                        .in(SecurityScheme.In.HEADER)<br>                                        .description(&quot;JWT auth description&quot;)));<br>    }<br><br>    @Bean<br>    public GroupedOpenApi publicApi() {<br>        return GroupedOpenApi.builder()<br>                .group(&quot;public&quot;)<br>                .pathsToMatch(&quot;/**&quot;)<br>                .build();<br>    }<br>}</pre><p>What this does:</p><ul><li>Defines a <strong>bearer token scheme</strong>.</li><li>Adds a global <strong>security requirement</strong> so endpoints recognize it.</li><li>Makes Swagger show the 🔑 <strong>Authorize button</strong> at the top right.</li></ul><h3>Step 2: Secure Your Controller Endpoints</h3><p>With one annotation, you tell Swagger which endpoints require authorization.</p><pre>@RestController<br>@RequestMapping(&quot;/orders&quot;)<br>@SecurityRequirement(name = &quot;authorization&quot;)<br>public class OrderController {<br><br>    @GetMapping<br>    public String getOrders() {<br>        return &quot;Order endpoint secured by token&quot;;<br>    }<br><br>    @PostMapping<br>    public String createOrder() {<br>        return &quot;Create order endpoint secured by token&quot;;<br>    }<br><br>    @PutMapping(&quot;/{id}&quot;)<br>    public String updateOrder(@PathVariable String id) {<br>        return &quot;Update order endpoint secured by token: &quot; + id;<br>    }<br><br>    @DeleteMapping(&quot;/{id}&quot;)<br>    public String deleteOrder(@PathVariable String id) {<br>        return &quot;Delete order endpoint secured by token: &quot; + id;<br>    }<br>}</pre><p>The <strong>@SecurityRequirement(name = &quot;authorization&quot;)</strong> annotation tells Swagger that every endpoint in this controller requires a token.</p><h3>Before vs After</h3><p>🔴 <em>Before</em>: Developer keeps Swagger for docs and Postman for testing tokens.<br> 🟢 <em>After</em>: Swagger does it all—documentation, testing, and token handling.</p><blockquote><strong>Screenshots — Highlights —</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uo-xYgEP7MikzevgmMEcjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qDeJj0d9px7H4PT2kPPxOw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6466610fcbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protect Your Data with Column-Level Encryption Using Jasypt in Spring Boot]]></title>
            <link>https://medium.com/@fasoft90/protect-your-data-with-column-level-encryption-using-jasypt-in-spring-boot-7104b4fc752a?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/7104b4fc752a</guid>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Sat, 08 Mar 2025 12:27:43 GMT</pubDate>
            <atom:updated>2025-03-08T12:27:43.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ADp4WaJdPeOgt-X.png" /></figure><p>In an era where data breaches are becoming increasingly common, securing sensitive information has never been more important. While full-database encryption can help safeguard data, there are times when you only need to encrypt specific columns containing sensitive information — like credit card numbers or personal identification details. This is where <strong>Column-Level Data Encryption</strong> becomes crucial.</p><p>In this article, I’ll walk you through how to implement column-level encryption in a Spring Boot application using the <strong>Jasypt</strong> library.</p><h3>Prerequisites</h3><p>Before we begin, here’s what you’ll need:</p><ul><li>A basic understanding of <strong>Java</strong> and <strong>Spring Boot</strong>.</li><li>An existing <strong>Spring Boot project</strong> where you can add dependencies and configurations.</li><li><strong>Jasypt dependency</strong> added to your project.</li><li>A relational database set up (we’ll use <strong>H2</strong> in-memory for this demo, but the approach applies to any relational database).</li></ul><h3>What is Column-Level Encryption?</h3><p>Column-Level Encryption is the practice of encrypting specific columns in a database rather than encrypting the entire database. This approach provides <strong>granular control</strong> over which data is encrypted, ensuring that sensitive information, such as <strong>Social Security Numbers (SSNs)</strong> or <strong>email addresses</strong>, is protected. Other less sensitive data (like <strong>user names</strong> or <strong>dates of birth</strong>) can remain unencrypted, optimizing performance.</p><p>By using column-level encryption, you protect sensitive data while allowing efficient querying and processing of non-sensitive data.</p><h3>Setting Up Your Spring Boot Project</h3><p>First, let’s configure our Spring Boot application to enable column-level encryption using <strong>Jasypt</strong>.</p><h4>1. Add the Jasypt Dependency</h4><p>To get started, add the following dependency to your pom.xml file to include the Jasypt library:</p><pre>&lt;!-- Jasypt Encryption Library --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.jasypt&lt;/groupId&gt;<br>    &lt;artifactId&gt;jasypt&lt;/artifactId&gt;<br>    &lt;version&gt;1.9.3&lt;/version&gt;<br>&lt;/dependency&gt;</pre><h4>2. Configure Your Application Properties</h4><p>Next, configure your application.yml (or application.properties) to include the necessary configurations for your H2 database and Jasypt encryption.</p><pre>server:<br>  port: 2003<br><br>spring:<br>  datasource:<br>    url: jdbc:h2:mem:employee-management-system<br>    username: sa<br>    password: password<br>    driverClassName: org.h2.Driver<br>  jpa:<br>    database-platform: org.hibernate.dialect.H2Dialect<br>  h2:<br>    console:<br>      path: /h2-console<br>      enabled: true<br>jasypt:<br>  encryptor:<br>    algorithm: PBEWithMD5AndDES<br>    password: ${JASYPT_PASSWORD:pass123}</pre><p>In the configuration above:</p><ul><li>We’re using <strong>H2</strong> as the in-memory database.</li><li>The <strong>Jasypt password</strong> is configurable via an environment variable (JASYPT_PASSWORD), or it defaults to pass123.</li></ul><h3>3. Create a Utility Class for Encryption/Decryption</h3><p>Now, let’s create a utility class to handle the encryption and decryption logic. This class will be used to <strong>convert entity attributes</strong> before saving them to the database.</p><pre>package zw.co.fasoft.employee;<br><br>import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;<br>import org.springframework.core.env.Environment;<br><br>import jakarta.persistence.AttributeConverter;<br>import jakarta.persistence.Converter;<br><br>/**<br> * JPA Attribute Converter for encrypting and decrypting String attributes. This<br> * converter uses the Jasypt library for encryption and decryption operations.<br> * It is configured with an environment variable for the encryption password.<br> * <br> * Note: Ensure that the Jasypt library is correctly configured in your project.<br> * The encryption password should be provided through the<br> * &quot;jasypt.encryptor.password&quot; property.<br> * <br> * @author rahul.chauhan<br> */<br>@Converter<br>public class StringCryptoConverter implements AttributeConverter&lt;String, String&gt; {<br><br>    // Property name for the encryption password<br>    private static final String ENCRYPTION_PASSWORD_PROPERTY = &quot;jasypt.encryptor.password&quot;;<br><br>    // Jasypt StringEncryptor for performing encryption and decryption<br>    private final StandardPBEStringEncryptor encryptor;<br><br>    /**<br>     * Constructor for StringCryptoConverter.<br>     * <br>     * @param environment The Spring Environment used to access properties.<br>     */<br>    public StringCryptoConverter(Environment environment) {<br>        // Initialize the encryptor with the encryption password from the environment<br>        this.encryptor = new StandardPBEStringEncryptor();<br>        this.encryptor.setPassword(environment.getProperty(ENCRYPTION_PASSWORD_PROPERTY));<br>    }<br><br>    /**<br>     * Converts the attribute value to the encrypted form.<br>     * <br>     * @param attribute The original attribute value to be encrypted.<br>     * @return The encrypted form of the attribute.<br>     */<br>    @Override<br>    public String convertToDatabaseColumn(String attribute) {<br>        return encryptor.encrypt(attribute);<br>    }<br><br>    /**<br>     * Converts the encrypted database value to its decrypted form.<br>     * <br>     * @param dbData The encrypted value stored in the database.<br>     * @return The decrypted form of the database value.<br>     */<br>    @Override<br>    public String convertToEntityAttribute(String dbData) {<br>        return encryptor.decrypt(dbData);<br>    }<br>}</pre><p>In the code above:</p><ul><li><strong>StringCryptoConverter</strong> is a JPA attribute converter that encrypts the String attributes when saving and decrypts them when loading.</li><li>The encryption password is read from the environment properties (jasypt.encryptor.password).<br>Go on to your Entity definition</li></ul><h3>4. Define Your Entity Class with Encrypted Fields</h3><p>Now, let’s create an entity class, Employee, where specific columns (like firstName and email) are encrypted using the StringCryptoConverter we just created.</p><pre>package zw.co.fasoft.employee;<br><br>import com.fasterxml.jackson.annotation.JsonFormat;<br>import io.swagger.v3.oas.annotations.media.Schema;<br>import jakarta.persistence.*;<br>import lombok.AllArgsConstructor;<br>import lombok.Builder;<br>import lombok.Data;<br>import lombok.NoArgsConstructor;<br>import zw.co.fasoft.employee.enums.EmployeeStatus;<br><br>import java.time.LocalDate;<br><br>/**<br> * Employee entity representing employee data in the system.<br> */<br>@Entity<br>@Table(name = &quot;employees&quot;)<br>@Data<br>@Builder<br>@AllArgsConstructor<br>@NoArgsConstructor<br>public class Employee {<br><br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    @Schema(description = &quot;The unique identifier of the employee (Auto Generated)&quot;, example = &quot;1&quot;)<br>    private Long id;<br><br>    @Schema(description = &quot;The first name of the employee&quot;, example = &quot;John&quot;)<br>    @Convert(converter = StringCryptoConverter.class)<br>    private String firstName;<br><br>    @Schema(description = &quot;The last name of the employee&quot;, example = &quot;Doe&quot;)<br>    private String lastName;<br><br>    @Schema(description = &quot;The unique employee number&quot;, example = &quot;EMP12345&quot;)<br>    private String employeeNumber;<br><br>    @Schema(description = &quot;The email address of the employee&quot;, example = &quot;john.doe@example.com&quot;)<br>    @Convert(converter = StringCryptoConverter.class)<br>    private String email;<br><br>    @Enumerated(EnumType.STRING)<br>    private EmployeeStatus status;<br><br>    @JsonFormat(pattern = &quot;yyyy-MM-dd&quot;)<br>    @Schema(description = &quot;The date of birth of the employee&quot;, example = &quot;1990-05-15&quot;)<br>    private LocalDate dateOfBirth;<br><br>    @JsonFormat(pattern = &quot;yyyy-MM-dd&quot;)<br>    @Schema(description = &quot;The hire date of the employee&quot;, example = &quot;2015-06-01&quot;)<br>    private LocalDate hireDate;<br>}</pre><p>In this entity:</p><ul><li>We’ve applied the @Convert(converter = StringCryptoConverter.class) annotation to the firstName and email fields to ensure that these fields are encrypted before being stored in the database.</li></ul><h3>Conclusion</h3><p>By following this approach, you’ve successfully implemented <strong>column-level encryption</strong> in your Spring Boot application using Jasypt. This allows you to secure only the sensitive parts of your database, while keeping the rest of the data accessible for efficient querying.</p><p>Remember to keep your <strong>encryption password</strong> secure by using environment variables, and always test your encryption/decryption flow to ensure it’s working as expected.</p><p>With column-level encryption, you can confidently protect sensitive user information and mitigate potential security risks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7104b4fc752a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Docker]]></title>
            <link>https://medium.com/@fasoft90/introduction-to-docker-3747823525c6?source=rss-eb1d3dafb0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3747823525c6</guid>
            <dc:creator><![CDATA[Farai Matsika]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 19:01:07 GMT</pubDate>
            <atom:updated>2025-02-05T19:01:07.010Z</atom:updated>
            <content:encoded><![CDATA[<p>Docker is a platform designed to simplify the process of developing, shipping, and running applications by using lightweight, portable containers. These containers bundle an application along with all its dependencies, libraries, and configuration files, creating a consistent environment regardless of where the application is deployed — whether on a developer’s machine, a testing server, or in production. Unlike virtual machines, containers share the host operating system’s kernel, making them more efficient, lightweight, and faster to start. Docker ensures that applications run reliably across different environments, eliminating the “it works on my machine” problem and streamlining the software development lifecycle.</p><p><strong>Why Use Docker?</strong></p><ul><li>Simplifies deployment by creating consistent environments.</li><li>Enables scaling and portability.</li><li>Supports isolation, which means that each container is independent of others.</li></ul><p>Docker revolves around several key concepts that simplify containerization.</p><p><strong>Images</strong> are read-only templates that define the blueprint for creating containers, including the application code, dependencies, and configurations.</p><p><strong>Containers</strong> are the running instances of these images, providing isolated environments where applications can execute.</p><p>A <strong>Dockerfile</strong> is a text file with a set of instructions used to automate the creation of Docker images, specifying how the image should be built step-by-step.</p><p>Finally, <strong>Docker Hub</strong> is a cloud-based registry where developers can share, store, and access Docker images, serving as a central repository for pre-built images or custom ones. These concepts work together to streamline application development and deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3747823525c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>