π A surprising Spring Boot moment I didn't expect — and the rabbit hole it took me down... π¬ It All Started With a Simple Idea... You know how it goes… You define a config value like this in application.properties : payment.currency=INR And then you boldly write this innocent-looking code: @Component public class PaymentUtil { @Value("${payment.currency}") private static String currency; // ✅ Logical! Right? public static void printCurrency() { System.out.println("Currency: " + currency); } } You run the app. And BAM π₯ Currency: null π΅ "Eh? I clearly defined the property. Is it not reading the file? Do I need a restart? Do I need to yell at my laptop?" π€― The Shocking Discovery Spring doesn’t inject values into static fields. Yes, my friend. Even if you beg it with @Value . And trust me — it’s not a bug. It’s a feature. π π§ What Is This Dependency Injection (DI) Sorcery ...
A cozy space where I share my daily Java learnings, issues, and solutions.