@Configuration vs @Component: why the distinction matters Both @Configuration and @Component register beans in the Spring context, but they serve different purposes. Key difference: @Component → Generic stereotype for auto-detected beans @Configuration → Specialization of @Component used for Java-based configuration What makes @Configuration important: It uses CGLIB proxies to ensure @Bean methods return singleton instances Prevents accidental creation of multiple bean instances Guarantees consistent behavior across the application Using @Component for configuration classes can lead to subtle bugs, especially when one @Bean method calls another. Understanding this distinction helps avoid issues that are hard to detect at runtime. 💬 Do you explicitly use @Configuration for all configuration classes? #SpringBoot #SpringFramework #Java #Configuration #BackendDevelopment #SoftwareEngineering
Spring Configuration vs Component: Understanding the Distinction
More Relevant Posts
-
When we migrated blocking IO and thread pools to Java 21 virtual threads, tail latency dropped 40–70% in I/O-bound services — yet most teams still ship buggy rollouts because they miss three engineering invariants. The pain: thread-pool assumptions are everywhere. Connection pools, ThreadLocal state, deadline propagation, and blocking libraries create hidden coupling that breaks when you switch to virtually unlimited threads. You can get raw wins fast, or you can get production incidents faster. Here’s a 3-step playbook I use to migrate safely, with concrete examples. 1
To view or add a comment, sign in
-
🌱 My Spring Journey : Dependency Lookup -> Here, the target class writes the logic to obtain the dependent class object, and for this it uses the getBean(..) method. -> If the dependent class object is required in multiple methods of the target class, we should prefer Dependency Injection; otherwise, we can go for Dependency Lookup. Limitations of Dependency Lookup : -> For this approach, we need to create or access an extra IOC container inside the business method of the target class. -> Due to this, even singleton-scoped Spring beans may get pre-instantiated multiple times (when multiple containers are created). -> This extra IOC container creation process generates in-memory metadata for the Spring bean configuration files, which can lead to memory issues. -> To overcome this problem we can use Interface injection #SpringFramework #DependencyLookup #DependencyInjection #Java #SpringCore #BackendDevelopment #LearningJourney
To view or add a comment, sign in
-
🚀 #ApproveJ 1.2 got released with 3 new modules! 🆕 http module can be used to approve HTTP requests done by your code! Complete with 🖨️ PrintFormat, 🧽 Scrubbers, and a 🥸 HttpStubServer (WireMock also supported) 🆕 json-/yaml-jackson3 modules support Jackson 3 ⚠️ all jackson modules no longer provide the Jackson dependencies, but require them to be declared in the project's dependencies #approvaltesting #snapshottesting #java #jvm https://lnkd.in/eRhujCit
To view or add a comment, sign in
-
-
Here is a mention of my last article with an illustrative picture The multiplicity of sources can sometimes lead to confusion and result in application misconfiguration. Especially since the misconfigured property can be difficult to identify if it prevents the application from starting and displaying sufficient logs to diagnose the problem. This article presents a solution to this problem: the early display of properties used in the application with the value actually taken into account by Spring Boot and the origin of this value #springboot #properties #java #configuration #YAML #misconfiguration https://lnkd.in/eGTw6Z9c
To view or add a comment, sign in
-
-
📌 LeetCode 904 – Fruit Into Baskets Key Logic: ➡️ Expand window using j ➡️ Track frequencies using HashMap ➡️ Shrink window when distinct fruits > 2 ➡️ Update maximum window size Fixed a subtle bug in the window contraction logic that improved correctness and edge-case handling. #SoftwareDevelopment #Java #DSA #TechJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 24 of #100DaysOfCode Zigzag Conversion – Approach Explanation Solved the Zigzag Conversion problem on LeetCode. 💡 Approach: If numRows == 1, return the string directly (edge case). Create an array of StringBuilder objects for each row. Traverse the string character by character: Append characters while moving downward. When reaching the bottom row, switch direction and move upward diagonally. Continue switching direction at the first and last rows. Finally, concatenate all rows to form the result. ⚡ Key Concept: This problem is about simulating movement in a zigzag pattern by controlling direction using a boolean flag. ⏱ Complexity: Time Complexity: O(n) Space Complexity: O(n) Efficient string manipulation and direction control were the main focus in this problem. #Day24 #100DaysOfCode #Java #DataStructures #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
🚀 Built a Concurrent Token Bucket Rate Limiter in Java I recently implemented a thread-safe Rate Limiter Engine using the Token Bucket algorithm in Java to understand how real systems control request bursts and ensure fair usage under concurrent load. This project simulates high concurrent traffic and enforces per-client rate limits using fine-grained locking and concurrent data structures. 🔧 Key Highlights: • Per-client token bucket rate limiting • Thread-safe design • ConcurrentHashMap for client → bucket mapping • ReentrantLock for safe token updates • Lazy refill strategy based on elapsed time (no scheduler thread) • Metrics tracking using AtomicLong counters • ExecutorService thread pool to simulate concurrent requests • Console UI for interactive testing 🧠 What I Focused On: Designing for correctness under concurrency — ensuring: no duplicate bucket creation no race conditions in token consumption parallel processing across different clients serialized access per client 📌 Concepts Used: Java Concurrency, Thread Pools, Locks, Concurrent Collections, Token Bucket Algorithm, Rate Limiting Design I also documented the system design and flow for interview-style explanation. GitHub repo: https://lnkd.in/gtwGzqtC Open to feedback and suggestions for improving this toward a distributed (Redis-based) rate limiter. #Java #Backend #SystemDesign #Concurrency #RateLimiting #TokenBucket #GitHubProjects
To view or add a comment, sign in
-
🚀 Day 15/100 - Dependency Injection (DI) - 2️⃣ 📌 Types of Dependency Injection Here is an overview of 3 different types of DI and when they are suitable to use 👇 ➡️ Constructor Injection 🔹Dependencies are passed through a constructor. 🔹Preferred for mandatory dependencies ➡️ Setter Injection 🔹Dependencies are set via setter methods. 🔹Suitable for optional dependencies ➡️ Field Injection 🔹Dependencies are injected directly into fields using @Autowired. 🔹Quick but less recommended for testing 📌 The attached image shows Spring Annotations mostly used for Dependency Injection 👇 Next post: https://lnkd.in/dtBYzsuB Previous post: https://lnkd.in/d3pztG-x #100Days #Java #SpringBoot #DependencyInjection #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 23 / 100 | Add Two Numbers -Approach : O(n) - Traverse both linked lists simultaneously. - Maintain a carry variable to handle sums that are greater than or equal to 10. - Use a ans node to simplify the construction of the result list. - At each step, compute the sum as: sum = val1 + val2 + carry. - Update the carry as carry = sum / 10 and store sum % 10 in a new node. - Continue this process until both lists and the carry are exhausted. - Finally, return ans.next. #100DaysOfCode #LeetCode #Java #DSA #LinkedList #ProblemSolving
To view or add a comment, sign in
-
-
Hook: In one production migration to Java 21 virtual threads we saw p99 latency jump 3× and tail latencies spiking during load — not because virtual threads were bad, but because a few synchronous hotspots and unbounded queues amplified contention. Body — A focused 3-step playbook
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