📌 Spring Boot Annotation Series Part 19 – @DeleteMapping @DeleteMapping is used to handle HTTP DELETE requests in a REST API. It is part of Spring Framework and is commonly used in RESTful services built with Spring Boot. 🔹 Why Do We Use @DeleteMapping? In REST APIs: GET → Fetch data POST → Create data PUT → Update data DELETE → Remove data @DeleteMapping handles delete operations. 🔹 What Happens Internally? @DeleteMapping is a shortcut for: @RequestMapping(method = RequestMethod.DELETE) So it is a specialized version of @RequestMapping. 🔹 In Simple Words @DeleteMapping connects an HTTP DELETE request to a controller method to remove a resource. #SpringBoot #Java #RESTAPI #DeleteMapping #BackendDevelopment #InterviewPreparation
Spring Boot @DeleteMapping: Handling HTTP DELETE Requests
More Relevant Posts
-
Understanding Key Annotations in Spring Boot Annotations make Spring Boot development simple and powerful. Let’s look at three important ones 👇 🔹 @Entity → Represents a table in the database → Each instance of the class maps to a row → Used in the data layer 🔹 @RestController → Handles HTTP requests and returns responses → Used to build REST APIs → Combines @Controller + @ResponseBody 🔹 @Service → Contains business logic of the application → Acts as a bridge between Controller and Repository ✅ In simple terms: • @RestController → Handles requests • @Service → Processes logic • @Entity → Represents data Understanding these annotations helps you see how different layers in Spring Boot work together. #SpringBoot #Java #BackendDevelopment #LearningInPublic #DeveloperGrowth
To view or add a comment, sign in
-
-
When working with APIs, you often need to pass data in the request. Spring Boot provides two common ways: @PathVariable and @RequestParam Example: @GetMapping("/users/{id}") public String getUser(@PathVariable int id) { return "User ID: " + id; } Here, id is part of the URL. Now using RequestParam: @GetMapping("/users") public String getUser(@RequestParam int id) { return "User ID: " + id; } Difference: • @PathVariable → part of URL path • @RequestParam → query parameter Example URLs: /users/10 → PathVariable /users?id=10 → RequestParam Choosing the right one improves API design. Next post: What is @RequestBody and how JSON is handled #Java #SpringBoot #BackendDevelopment #APIDesign
To view or add a comment, sign in
-
-
Hi everyone 👋 📌 Spring Boot Annotation Series Part 20 – @PatchMapping @PatchMapping is used to handle HTTP PATCH requests for partial updates in REST APIs. It is part of the Spring Framework and widely used in applications built with Spring Boot. 🔹 Why Do We Need PATCH? In REST: PUT → Full update (replace entire object) PATCH → Partial update (update specific fields only) If we only want to update one or two fields, using PUT would require sending the entire object. 👉 PATCH is more efficient. 🔹 What Happens Internally? @PatchMapping is a shortcut for: @RequestMapping(method = RequestMethod.PATCH) 🔹 In Simple Words @PatchMapping updates only the fields that are sent in the request. #SpringBoot #Java #RESTAPI #PatchMapping #BackendDevelopment #InterviewPreparation
To view or add a comment, sign in
-
When building APIs in Spring Boot, you’ll see multiple mapping annotations. But what’s the difference? @RequestMapping → Generic mapping (can handle all HTTP methods) @GetMapping → Used for GET requests (fetch data) @PostMapping → Used for POST requests (create data) Example: @RestController @RequestMapping("/users") public class UserController { @GetMapping public List<String> getUsers() { return List.of("A", "B"); } @PostMapping public String createUser() { return "User created"; } } Modern Spring Boot prefers specific annotations like @GetMapping for clarity. Rule of thumb: GET → Read POST → Create PUT → Update DELETE → Remove Next post: What is @PathVariable and @RequestParam #Java #SpringBoot #APIDevelopment #BackendDevelopment
To view or add a comment, sign in
-
Hi everyone 👋 📌 Spring Boot Annotation Series Part 22– @RequestParam @RequestParam is used to read query parameters from the request URL and bind them to method parameters. It is part of the Spring Framework and commonly used in REST APIs built with Spring Boot. 🔹 Why do we use @RequestParam? Sometimes we need to pass additional information through the URL. Example: GET /users?age=25 Here, age is a query parameter. @RequestParam helps us capture that value in the controller method. 🔹 Simple Example @RestController @RequestMapping("/users") public class UserController { @GetMapping("/search") public String getUserByAge(@RequestParam int age) { return "User age is: " + age; } } 👉 Request URL: GET http://localhost:8080/users/search?age=25 Output: User age is: 25 🔹 In Simple Words @RequestParam takes values from query parameters in the URL and passes them to the controller method. 👉 🧠 Quick Understanding Used in filtering, search APIs Can be optional using required=false Can provide default values Used to read query parameters from URL Mostly used in GET APIs #SpringBoot #Java #RESTAPI #RequestParam #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
New to Spring Boot? You'll see these annotations in every project. Here's what they actually do: @SpringBootApplication → Entry point. Combines @Configuration, @EnableAutoConfiguration, @ComponentScan @RestController → Marks a class as an HTTP request handler that returns data (not views) @Service → Business logic layer. Spring manages it as a bean @Repository → Data access layer. Also enables Spring's exception translation @Autowired → Inject a dependency automatically (prefer constructor injection instead) @GetMapping / @PostMapping / @PutMapping / @DeleteMapping → Maps HTTP methods to your handler methods @RequestBody → Deserializes JSON from request body into a Java object @PathVariable → Extracts values from the URL path Bookmark this. You'll refer back to it constantly. Which annotation confused you the most when starting out? 👇 #Java #SpringBoot #Annotations #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
👉 Understanding @PathVariable vs @RequestParam While building REST APIs in Spring Boot, we often need to send data from the URL to the controller. Two common ways to do this are: ➡ @PathVariable ➡ @RequestParam 🔹 1. @PathVariable @PathVariable is used to extract values directly from the URL path. Example URL: http://localhost:8080/users/10 Example Code: @GetMapping("/users/{id}") public String getUser(@PathVariable int id) { return "User ID: " + id; } ✔ Used when the value is part of the resource path ✔ Common in RESTful APIs 🔹 2. @RequestParam @RequestParam is used to extract query parameters from the URL. Example URL: http://localhost:8080/users?id=10 Example Code: @GetMapping("/users") public String getUser(@RequestParam int id) { return "User ID: " + id; } ✔ Used for filtering, searching, or optional parameters 🧠 Simple Way to Remember 👉 PathVariable → Part of URL path 👉 RequestParam → Extra data in query #SpringBoot #Java #RestAPI #BackendDevelopment #LearningInPublic #JavaDeveloper
To view or add a comment, sign in
-
Understanding Annotations in Spring Boot: Annotations play a key role in how Spring Boot applications are built and configured. But what exactly are they? Annotations are metadata added to Java code that tell the Spring framework how to behave or configure certain components. Instead of writing large configuration files, Spring Boot uses annotations to simplify development. Some commonly used annotations include: 🔹 @SpringBootApplication Marks the main class and enables auto-configuration, component scanning, and configuration support. 🔹 @RestController / @Controller Used to handle incoming HTTP requests and return responses. 🔹 @Service Indicates that a class contains business logic. 🔹 @Repository Used for database interaction and persistence operations. 🔹 @Autowired Allows Spring to automatically inject dependencies. ✅ These annotations help reduce boilerplate code and make Spring Boot applications easier to build and manage. Understanding how and why annotations are used is an important step toward mastering Spring Boot. #SpringBoot #Java #BackendDevelopment #SoftwareDevelopment
To view or add a comment, sign in
-
🚀 Day 55/100 - Spring Boot - Logging Once your application is running in production, System.out.println() is not enough ❌ You need structured, configurable, and production-ready logging❗ For that, spring boot uses: 🔹SLF4J (Logging API / facade) 🔹Logback (Default implementation) ➡️ Why Logging Matters? Because it helps you: ✔ Monitor application behavior ✔ Debug issues in production ✔ Track errors ✔ Audit important events ✔ Analyze system health Good logging = easier debugging = better reliability ➡️ SLF4J and Logback 🔹 SLF4J (Simple Logging Facade for Java) 🔹It’s a logging abstraction 🔹Allows switching logging frameworks (Logback, Log4j, etc.) 🔹Spring Boot includes it by default Think of it as an interface for logging. ➡️ Basic Logging Example (see attached image 👇) ➡️ Different Log Levels & their Purpose TRACE: used for very detailed debugging DEBUG: used for development debugging INFO: used for general application events WARN: used for something unexpected ERROR: used for serious problems ➡️ Best Practices ✔ Use INFO for important business events ✔ Use WARN for suspicious behavior ✔ Use ERROR for failures ✔ Avoid excessive logging Previous post: https://lnkd.in/dZVkgwcD #100Days #SpringBoot #Logging #SLF4J #Logback #Java #BackendDevelopment #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
🔹 Spring Concept: Bean Lifecycle In the Spring Framework, every object managed by the Spring IoC container is called a Bean. Understanding the Bean Lifecycle helps developers control how objects are created, initialized, and destroyed. 📌 Stages of Spring Bean Lifecycle 1️⃣ Instantiation Spring creates the bean instance. 2️⃣ Dependency Injection Spring injects required dependencies. 3️⃣ Initialization Custom initialization logic runs using: • @PostConstruct • InitializingBean • custom init-method 4️⃣ Bean Ready for Use The bean is now fully initialized and used in the application. 5️⃣ Destruction When the application context closes, cleanup logic runs using: • @PreDestroy • DisposableBean • custom destroy-method 💡 Example: @Component public class NotificationService { @PostConstruct public void init() { System.out.println(“Bean Initialized”); } @PreDestroy public void destroy() { System.out.println(“Bean Destroyed”); } } ✨ Understanding the Bean lifecycle helps developers manage resources efficiently and write better Spring applications. #Java #SpringBoot #SpringFramework #BackendDevelopment #SoftwareEngineering
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
Asmita Sethiya Clean explanation! Small abstractions like these play a big role in keeping REST APIs readable and consistent, especially when the number of endpoints grows in a production service.