Spent 10 minutes wondering why my Spring Boot application was not picking up environment variables. The code looked fine: @Value("${DATABASE_URL}") private String databaseUrl; No errors at startup. But the value was always null. The problem: I was using underscores in the property name, but Spring expects dots or lowercase with hyphens. The fix: @Value("${database.url}") private String databaseUrl; And in application_properties: database.url=${DATABASE_URL} One mapping. That was it. Spring does not automatically convert environment variable names to property names. You need to map them explicitly. What environment variable issue has caught you off guard? #Java #SpringBoot #EnvironmentVariables #Debugging #BackendDevelopment
Spring Boot Environment Variable Issue with Underscores
More Relevant Posts
-
Ever wondered how Spring Boot sets up a DataSource, EntityManagerFactory, and transactions — without you writing a single line of config? That's auto-configuration. And I just wrote my first blog post breaking down exactly how it works. What's covered: → The role of META-INF/spring/AutoConfiguration.imports → @ConditionalOnClass, @ConditionalOnMissingBean, @ConditionalOnProperty → How condition evaluation happens before any bean is created If you've ever typed @SpringBootApplication and moved on without questioning it — this one's for you. This is my first blog, so if I've missed anything or something could be explained better — feel free to drop a comment. Happy to discuss and improve! 🔗 Link in the comments! #SpringBoot #Java #Backend
To view or add a comment, sign in
-
-
🚀 Mastering Spring Boot – Step by Step (Day 2) Still using "new" in Spring? ❌ 👉 Then you’re missing the core idea of Spring 💡 What is a Spring Bean? A Bean is: 👉 Any object managed by the Spring IoC container Instead of: UserService service = new UserService(); Spring does: ✔ Create objects ✔ Manage lifecycle ✔ Connect components 💡 What is IoC (Inversion of Control)? 👉 You don’t control object creation anymore 👉 Spring does it for you This leads to: ✔ Cleaner code ✔ Loose coupling ✔ Better scalability 💡 Simple way to think: You: "I will create objects" ❌ Spring: "I will handle everything" ✅ 👉 This is the foundation of Spring Next → Dependency Injection (real magic begins) 🔥 #Spring #SpringBoot #Java #Backend #LearningInPublic
To view or add a comment, sign in
-
🚨 Why I stopped using field injection in Spring Boot I used to write this: @Autowired private UserService userService; Looks clean… but caused real issues. ❌ Problems: * Hard to test * Hidden dependencies * NullPointer risks in edge cases ✅ Now I always use constructor injection: public UserController(UserService userService) { this.userService = userService; } 💥 Real benefit: While writing unit tests, I realized I could mock dependencies easily without Spring context. 💡 Takeaway: Field injection is convenient. Constructor injection is production-safe. Small change. Big impact. #Java #SpringBoot #BackendDevelopment #SoftwareEngineering #Microservices #RESTAPI #SystemDesign #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
Spring Boot Filters vs Interceptors — Most developers confuse this 🤯 Let’s simplify 👇 ✅ Filter (Servlet level) - Works BEFORE DispatcherServlet - Used for logging, authentication, request modification ✅ Interceptor (Spring level) - Works AFTER DispatcherServlet - Used for business-level checks 💡 Flow: Request → Filter → DispatcherServlet → Interceptor → Controller ⚡ Real use case: - Filter → JWT validation - Interceptor → role-based access 👉 Choosing wrong = messy architecture Know the difference = cleaner backend 🔥 #SpringBoot #Java #BackendDeveloper
To view or add a comment, sign in
-
Spring Boot Bean Scope — Not just Singleton 🤯 Most developers only know this: 👉 Default scope = Singleton But there’s more 👇 ✅ Prototype → New instance every time ✅ Request → Per HTTP request ✅ Session → Per user session 💡 Why it matters: ✔ Memory optimization ✔ Better state handling ⚠️ Mistake: Using singleton for stateful data ❌ 👉 Leads to concurrency issues 🔥 Real lesson: Choose scope based on use case, not default Backend bugs often start here 🚨 #SpringBoot #Java #Architecture
To view or add a comment, sign in
-
🚨 Spring Boot Trap @Transactional looks simple. But it has rules. It works when: • Called from another bean • Public methods • Proxy is active It fails silently when: • Self-invocation • Wrong propagation • Async methods Result? Data inconsistency. Always test transaction boundaries. Don’t assume they work. #SpringBoot #Java #Transactions #Backend #BackendDevelopment #JavaDeveloper #SoftwareEngineering #TechTips #SoftwareEngineer
To view or add a comment, sign in
-
-
🚀 Day 20/100: Spring Boot From Zero to Production Topic: Custom Auto-Configuration We covered Auto-Configuration. We covered disabling it. But does it stop there? Nope. 👀 Spring Boot lets you build your own auto-configuration too. 🔧 But, How It Works? You create a @Configuration class and slap conditionals on it. Spring Boot only loads it if your conditions are met. Two most common ones: @ConditionalOnClass → Load only if a class exists on the classpath @ConditionalOnProperty → Load only if a property is set in application.properties 💡 See the code attached below. ⬇️ No DataSource on classpath? → Skipped entirely db.enabled=false? → Skipped entirely Bean already defined by user? → Your default is skipped ✅ 📌 Don't forget to register it In META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -> com.yourpackage.MyDataAutoConfiguration Without this, Spring Boot won't pick it up. Checkout the previous posts on Auto-Config & disabling it to better understand the sequence. See you in the next one! #Java #SpringBoot #SoftwareDevelopment #100DaysOfCode #Backend #AutoConfiguration
To view or add a comment, sign in
-
-
Most developers use threads in Spring Boot without ever needing to think about what is happening underneath. I did too until I realized that some performance issues are not caused by slow code, but by how the application is handling work internally. Understanding threads changed the way I think about background tasks, request handling, and scalability in Java applications. I wrote about how Spring Boot threads work, how to configure them properly, and when using them can improve or complicate your system. Read more here: https://lnkd.in/ePmp5rMa
Spring Boot Threads Explained: How They Work, How to Configure Them, and When to Use Them medium.com To view or add a comment, sign in
-
🧠 My Spring Boot API just became more production-ready today 👀 I implemented Global Exception Handling 🚀 Before this 👇 ❌ Errors returned messy stack traces ❌ No clear message for users Now 👇 ✅ Clean JSON error responses ✅ Proper HTTP status codes ✅ Centralized error handling Example 👇 { "message": "User not found", "status": 404 } 💡 My takeaway: Handling errors properly is what separates a basic API from a production-ready backend ⚡ #Java #SpringBoot #ExceptionHandling #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
Spring Boot Bean Lifecycle — Most developers ignore this 🔥 Do you know what happens before your bean is ready? Here’s the flow 👇 1️⃣ Bean Instantiation 2️⃣ Dependency Injection 3️⃣ @PostConstruct runs 4️⃣ Bean is ready to use ✅ And before shutdown: 👉 @PreDestroy is called 💡 Why it matters: ✔ Resource initialization ✔ Cleanup logic ✔ Better control over application lifecycle ⚠️ Mistake: Putting heavy logic inside constructors ❌ 👉 Use @PostConstruct instead Understanding lifecycle = writing smarter Spring Boot apps 🚀 #SpringBoot #Java #BackendDeveloper
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Spring Boot's relaxed binding helps, but environment variables with underscores still need explicit mapping. Now I always double-check my property names when using external configuration.