🌱 This week I finally connected the dots between Filters and Interceptors in Spring Boot — and now every incoming request makes a lot more sense. Here’s how I see it now: 🧩 Filter — sits at the Servlet layer, runs before the request even reaches Spring MVC. It’s the bouncer at the door — checks JWTs, logs requests, or just decides who gets in. ⚙️ Interceptor — works inside the Spring MVC flow, right before the Controller. It’s more like the assistant inside the club — setting things up, verifying roles, or cleaning up after the show. Now when I debug a request, I can clearly trace the path: Client → Filter → DispatcherServlet → Interceptor → Controller → Response It looks simple, but once you really understand it — it makes a lot more sense. One more Spring Boot concept truly understood. 🌿 #SpringBoot #Java #BackendDevelopment #LearningJourney
Understanding Filters and Interceptors in Spring Boot
More Relevant Posts
-
Spring Boot Scenario-Based Questions Here are some real-world Spring Boot scenarios you might face during development : Scenario 1: You are working on a Spring Boot application that requires loading different configurations for development and production environments. How to achieve it?... Scenario 2: You have a service class that needs to be injected into multiple controllers. What are the different ways to achieve this in Spring Boot? Scenario 3: You have a REST API, and when an invalid ID is provided, it should return a custom error message with a 404 Not Found status. How would you handle this? Scenario 4: You need to log events in your application instead of using System.out.println(). How would you do it? Scenario 5: You have an API that fetches user details based on the user Id. How would you capture it in Spring Boot? Which annotation would you use? 💬 Interested ones, share your answers or thoughts in the comments below! #SpringBoot #JavaDevelopers #BackendDevelopment #CodingInterview #SpringFramework #ProblemSolving #Java
To view or add a comment, sign in
-
🧩 Spring Boot Tip: Simplify Dependency Injection with @Autowired Constructor! Want cleaner beans and easier testing? Use constructor injection with Spring’s @Autowired on constructors—making your dependencies explicit and your classes immutable. ✨ Example: @Service public class UserService { private final UserRepository userRepository; @Autowired public UserService(UserRepository userRepository) { this.userRepository = userRepository; } } Benefits: Easier unit testing, mandatory dependency injection, and clearer design. 💡 Pro Tip: Starting from Spring 4.3, @Autowired on constructors is optional if the class has a single constructor. How do you prefer to inject dependencies in your Spring apps? Share your favorite DI style! #SpringBoot #Java #DependencyInjection #Autowired #CleanCode #BackendTips #DesignPatterns
To view or add a comment, sign in
-
My "perfect" Spring Boot code took 49 seconds. The same operation with JDBC? 108 milliseconds. That's 460x faster. 🤯 I couldn't believe it, so I ran 6 comprehensive tests with 40,000+ records. The results shocked me: - Bulk inserts: 460x difference - Single operations: 15x faster (even with JPA cache!) - Complex queries: 17x faster - Deletes: 50x faster But here's the twist → JPA isn't the problem. It's knowing WHEN to use what. I tested everything and documented it with real numbers: 👉 https://lnkd.in/gKmSihHn Have you checked your bulk operations lately? 👀 #SpringBoot #Java #Performance #SoftwareEngineering
To view or add a comment, sign in
-
-
𝗜𝗳 𝘆𝗼𝘂 𝘂𝘀𝗲 𝗝𝗥𝗘... 𝘄𝗵𝘆 𝗱𝗼 𝘆𝗼𝘂 𝘀𝘁𝗶𝗹𝗹 𝗻𝗲𝗲𝗱 𝗝𝗩𝗠? Most devs get this backward. Let’s fix it once and for all. You don’t 𝘳𝘶𝘯 Java with JRE. You 𝘳𝘶𝘯 Java 𝗶𝗻𝘀𝗶𝗱𝗲 the JVM. The 𝗝𝗥𝗘 is just the environment — it gives the 𝗝𝗩𝗠 what it needs to do its job: standard libraries, config files, runtime support. Think of it like this 👇 • 𝗝𝗩𝗠 → the engine • 𝗝𝗥𝗘 → the car that holds the engine • 𝗝𝗗𝗞 → the factory that builds the car You don’t drive an engine. You drive a car. The car uses the engine to move. Same with Java. The 𝗝𝗥𝗘 𝘂𝘀𝗲𝘀 𝘁𝗵𝗲 𝗝𝗩𝗠 to run your code. Once you get this mental model, Everything about Java’s ecosystem suddenly clicks. #java #jre #jvm
To view or add a comment, sign in
-
-
Today I learned something interesting about Spring Boot’s @Async annotation. I was debugging why an async method wasn’t actually running in parallel — and eventually realized it was because I was calling it from within the same class. Since the call never went through the Spring proxy, the @Async behavior didn’t trigger. Lesson: @Async only works when the method is invoked through a Spring-managed proxy — not via direct internal calls within the same bean. Moving the method to a separate service (or injecting the bean itself via a proxy) fixed it instantly. A small reminder that many “magic” framework features are really just smart proxies under the hood — and understanding how they work can save hours of debugging. Have you ever run into similar proxy or async surprises in Spring Boot? #TodayILearned #SpringBoot #Java #Microservices #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
Spring Boot injection: why constructors win When wiring dependencies in Spring Boot, constructor injection consistently beats field injection. Why it matters Immutability: collaborators can be final, reducing accidental mutation. Testability: easy to pass fakes/mocks without Spring context. Clarity: dependencies are explicit at object creation. @RequiredArgsConstructor @Service public class InvoiceService { private final PaymentClient paymentClient; private final InvoiceRepo repo; } Pro tips Use @RequiredArgsConstructor (Lombok) or write constructors yourself. Keep constructors small; if there are too many params, you likely need to split responsibilities. Pair with @ConfigurationProperties instead of sprinkling @Value. #Java #SpringBoot #CleanCode #Testing #OOP
To view or add a comment, sign in
-
𝐑𝐚𝐭𝐞 𝐋𝐢𝐦𝐢𝐭𝐢𝐧𝐠: 𝐒𝐚𝐯𝐞 𝐘𝐨𝐮𝐫 𝐀𝐏𝐈 𝐟𝐫𝐨𝐦 𝐀𝐛𝐮𝐬𝐞 Implement rate limiting to protect your backend from 𝐃𝐃𝐨𝐒, 𝐛𝐫𝐮𝐭𝐞 𝐟𝐨𝐫𝐜𝐞, or abusive clients. Use token bucket or sliding window algorithms — libraries like 𝐑𝐞𝐬𝐢𝐥𝐢𝐞𝐧𝐜𝐞4𝐣 or 𝐁𝐮𝐜𝐤𝐞𝐭4𝐣 make it easy in Java/Spring. 𝐋𝐞𝐬𝐬𝐨𝐧 𝐋𝐞𝐚𝐫𝐧𝐞𝐝: Rate limiting prevents API abuse and ensures fair usage. For example, allowing only 5 requests per minute per IP keeps your service stable under load (not practical). 𝐁𝐮𝐜𝐤𝐞𝐭4𝐣 with Spring Boot simple implementation. #BackendDevelopment #SystemDesign #API #Java #SpringBoot
To view or add a comment, sign in
-
-
Spring Container & Component Scanning The Spring Container manages object creation, wiring, and bean lifecycle. It reads configuration metadata to build your application structure. Using @ComponentScan, Spring auto-detects beans in specified packages. Together, they enable clean, modular, and maintainable applications. #SpringFramework #Java #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
Before the release of Spring Boot 4, it was necessary to explicitly include the following dependency for JSON serialization and deserialization: <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> </dependency> However, starting with Spring Boot 4.0.x, this functionality is included with the spring-boot-starter-webmvc artifact or dependency as a tool with dependency as a spring-boot-starter-jackson, and the import changes accordingly, exhibiting a transitive nature. For more details about Jackson 3 support in Spring Boot 4, please read through https://lnkd.in/gvGN58M7 Spring I/O #springboot4 #springframework #java
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