Home – Datmt

  • Add CORS Configure For Spring Boot App

    Add CORS Configure For Spring Boot App

    Table of Contents1 Overview2 Create a CORS filter3 Configure the filter in your Security config4 Conclusion Overview When connecting from frontend to backend, you may encounter the infamous CORS error I will not explain to you what CORS error is (there are plenty of good resource for that). I only show you how to configure…

    Read More


  • Build Vite+React For Production With Nginx

    Table of Contents1 Overview2 How to fix axios error when running vite build3 Adding Dockerfile and nginx.conf4 Conclusion Overview Recently I struggled with building my new app with Vite+React for production. The issue was something to do with _global in the recent axios versions. When running npm run build So here is how I fixed…

    Read More


  • Using AI To Generate Git Commit Message For Free

    Using AI To Generate Git Commit Message For Free

    Table of Contents1 Overview2 Step by step to configure auto commit message2.1 Step 1: Create a Groq account and API key2.2 Step 2: Configure your GROQ_API_KEY environment variable2.3 Step 3: Create the script for prepare-commit-msg hook2.4 Skipping LLM3 Conclusion Overview Do you love writing commit messages? If so, you can return to your development now…

    Read More


  • 6 Ways To Directly Initialize a HashMap in Java

    6 Ways To Directly Initialize a HashMap in Java

    Table of Contents1 1. Using Map.of() (Java 9+)2 2. Using Map.ofEntries() (Java 9+)3 3. Using the Double Brace Initialization (Not Recommended)4 4. Using Stream API (Java 8+)5 5. Using Map.copyOf() (Java 10+)6 6. Mutable Initialization with Java 17’s Text Blocks7 Conclusion Java provides several ways to initialize a HashMap directly, making your code more concise…

    Read More


  • Using MessageSource In Spring Boot Application

    Using MessageSource In Spring Boot Application

    Table of Contents1 Overview2 I18n and l10n2.1 Internationalization2.2 Localization3 MessageSource in spring boot3.1 Key concepts3.1.1 MessageSource3.1.2 Message Bundles3.2 Common MessageSource implementations3.2.1 ResourceBundleMessageSource:3.2.2 ReloadableResourceBundleMessageSource:3.3 Structure of message bundles4 MessageSource basic example4.1 Configure the MessageSource bean5 Specifying Locale5.1 Creating custom resolver6 Cheat Sheet for Writing Messages in Message Bundles6.1 Basic usage6.2 Parameterized Messages6.3 Default Messages6.4 Multiline Messages6.5…

    Read More