🚀 Day 19/100: Spring Boot From Zero to Production Topic: Disabling Auto Configuration Quick Recap previously we covered Auto Configuration in Spring Boot. (Link to that post in the comments 👇) The Problem: Auto Configuration is magical. But magic shouldn't cage you. Sometimes you need to go beyond the defaults. Sometimes a specific auto config just gets in your way. So the question is.... does Spring Boot let you opt out? Absolutely. And it's dead simple. ✅ How to Disable Auto Configuration: Just add an exclude to your @SpringBootApplication annotation: @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) public class MunasibApplication{ public static void main(String[] args) { SpringApplication.run(MyApp.class, args); } } That's it. One line. No database auto-wiring. Done. Not Just DataSource You're not limited to one config. Exclude multiple auto configurations at once Works with any AutoConfiguration class Spring Boot ships @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class }) Alternative: Use application.properties Don't want to touch your code? spring.autoconfigure.exclude=\org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration Same result. Zero code change. 🎯 Why This Matters Spring Boot gives you sensible defaults. But it never forces them on you. That's what makes it a great framework, not just smart, but flexible. #Java #SpringBoot #SoftwareDevelopment #100DaysOfCode #AutoConfiguration
Disabling Auto Configuration in Spring Boot
More Relevant Posts
-
What actually happens when you hit a Spring Boot API? In my previous post, I explained how Spring Boot works internally. Now let’s go one level deeper 👇 What happens when a request hits your application? --- Let’s say you call: 👉 GET /users Here’s the flow behind the scenes: 1️⃣ Request hits embedded server (Tomcat) Spring Boot runs on an embedded server that receives the request. --- 2️⃣ DispatcherServlet takes control This is the core of Spring MVC. It acts like a traffic controller. --- 3️⃣ Handler Mapping DispatcherServlet finds the correct controller method for the request. --- 4️⃣ Controller Execution Your @RestController handles the request → Calls service layer → Fetches data from DB --- 5️⃣ Response conversion Spring converts the response into JSON using Jackson. --- 6️⃣ Response sent back Finally, the client receives the response. --- Why this matters? Understanding this flow helps in: ✔ Debugging production issues ✔ Writing better APIs ✔ Improving performance Spring Boot hides complexity… But knowing what’s inside makes you a better backend developer. More deep dives coming #Java #SpringBoot #BackendDevelopment #Microservices
To view or add a comment, sign in
-
Spring Boot feels like magic… until you understand what is actually happening behind the scenes. One concept that confused me for a long time: 👉 Auto Configuration in Spring Boot At first, it really feels magical. "I just added a dependency… and everything started working 😄" No XML. No manual bean setup. No configuration chaos. Just run the app → it works. But then one question hits: How does Spring Boot decide what to configure and what to ignore? The answer is Auto Configuration Spring Boot tries to automatically configure your application based on what it finds in the classpath and your setup. Example: * Add H2 DB → in-memory DB gets configured * Add MySQL driver → DataSource changes automatically * Define your own bean → Spring backs off But here is the real insight most people miss: 👉 Auto Configuration is NOT magic. It is powered by Conditional logic Spring Boot constantly evaluates conditions like: * Is a class present in classpath? * Has the user already defined a bean? * Is a property set in application.yml? Based on that, it decides: 👉 "Should I create this bean… or skip it?" This is implemented using: * @ConditionalOnClass * @ConditionalOnMissingBean * @ConditionalOnProperty So the mental model becomes: Auto Configuration = what happens automatically Conditional Annotations = why it happens What I realized later is: Spring Boot does not remove control from you. It gives you smart defaults… and steps aside when you take control. That is why it feels magical at first but becomes obvious once you understand the design. #SpringBoot #Java #SpringFramework #Microservices #TechCareers #BuildInPublic
To view or add a comment, sign in
-
🧬 Mini Project – User API with Spring Boot 🚀 Built my first simple User API using Spring Boot and it gave me a clear understanding of how backend systems work. 🧠 What I implemented: ✔️ POST "/user" → Create a user ✔️ GET "/user/{id}" → Fetch user by ID 💡 Key Concepts Applied: • @RestController, @RequestBody, @PathVariable • JSON request & response handling • Layered architecture: Controller → Service → Data 🔁 Flow: Client → Controller → Service → In-memory data → JSON response 🧪 Tested APIs using Postman and successfully created & retrieved user data. 🚀 Next Steps: • Add validation • Integrate database (MySQL) • Implement exception handling 💻 DSA Practice: • Finding longest word in a sentence • Counting number of words ✨ This mini project helped me connect theory with real backend development. #SpringBoot #Java #BackendDevelopment #RESTAPI #MiniProject #DSA #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
Spring Boot in Real Projects — Day 19 We already know how APIs return data. But what happens when your application grows and starts handling hundreds or even thousands of tasks daily whether from a single user or many users? For example: User1 → 50 tasks User2 → 120 tasks User3 → 300 tasks It's simple to fetch data for user-1 and next user-2 with 120 tasks gets heavy to fetch and for the next user-3 its hard to fetch and the API response may gets slow, to solve this Pagination & Sorting come in What is Pagination? Pagination is the process of dividing data into smaller chunks (pages) and fetching only the required portion instead of loading everything at once. What is Sorting? Sorting allows us to order data based on a specific field like createdAt, title, etc. Flow Client → Controller → Pageable → Repository → Database (applies LIMIT, OFFSET, ORDER BY) → Returns Page → Response to Client #SpringBoot #Java #BackendDevelopment #Pagination #APIDesign #SoftwareEngineering
To view or add a comment, sign in
-
-
I used to think Spring Boot was just “another framework”… Until I actually started building with it. 🚀 Here are the core concepts of Spring Boot that completely changed how I see backend development: 👇 🔹 Auto-Configuration No more manual setup. Add a dependency → Spring Boot configures it for you. 🔹 Starter Dependencies Instead of adding 10 dependencies, you just use one: 👉 spring-boot-starter-web 🔹 Embedded Server No need for external Tomcat. Just run your app and it works. 🔹 Dependency Injection (DI) Spring manages objects for you → cleaner, loosely coupled code. 🔹 Inversion of Control (IoC) You don’t control object creation anymore — Spring does. 🔹 Spring MVC Architecture Controller → Service → Repository → Database (Simple, structured, scalable) 🔹 Spring Data JPA No need to write SQL for basic operations. Just use interfaces. 🔹 application.properties All configurations in one place → clean and manageable. 💡 What I realized: Spring Boot isn’t about writing less code… It’s about writing better, scalable code faster. What concept confused you the most when you started Spring Boot? 🤔 #Java #SpringBoot #BackendDevelopment #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
What I learned today while exploring Spring Boot. Instead of just going through theory, I focused on understanding how Controllers actually work in a real backend application. Here’s what I covered: 🔹 @RestController — used to expose REST APIs and return data directly (JSON/XML) 🔹 @Controller — mainly used for returning views (like in MVC-based applications) 🔹 Mapping requests properly using: → @RequestMapping (base mapping) → @GetMapping (fetch data) → @PostMapping (create data) → @PutMapping (update data) → @DeleteMapping (delete data) → @PatchMapping (partial update) 🔹 Handling client input: → @PathVariable for dynamic values in URL → @RequestParam for query parameters → @RequestBody for sending JSON data What I’m realizing is — Controllers are not just annotations, they define how the client and backend communicate. Focusing more on clarity and real usage rather than just memorizing. Learning step by step ⚡ #SpringBoot #Java #RestAPI #LearningJourney #Consistency #LearningJourney #Consistency
To view or add a comment, sign in
-
💡 application.properties vs application.yml – Configuration Styles in Spring Boot Choosing the right configuration format in Spring Boot can impact both readability and maintainability of your application. Here’s a concise comparison 🔹 application.properties A traditional key-value format widely used across Spring applications. Example: server.port=8080 spring.datasource.url=jdbc:mysql://localhost:3306/mydb spring.datasource.username=root spring.datasource.password=1234 ✔ Simple and familiar ✔ Easy to get started ✔ Suitable for smaller configurations 🔹 application.yml A YAML-based format that supports hierarchical structuring. Example: server: port: 8080 spring: datasource: url: jdbc:mysql://localhost:3306/mydb username: root password: 1234 ✔ Cleaner and more readable for complex setups ✔ Reduces repetition through nesting ✔ Better suited for large-scale applications Key Comparison AspectpropertiesymlStructureFlat (key-value)HierarchicalReadabilityModerateHigh (for complex)MaintenanceSlightly harderEasier at scaleLearning CurveMinimalRequires YAML basics⚡ Recommendation Use .properties for simple or quick configurations Use .yml when working with structured, multi-level configurations Both formats are fully supported by Spring Boot and can be used interchangeably based on team preference and project needs. #SpringBoot #Java #SoftwareEngineering #Backend #ConfigurationManagement
To view or add a comment, sign in
-
-
Clean REST API in Spring Boot (Best Practice) 🚀 Here’s a simple structure you should follow 👇 📁 Controller - Handles HTTP requests 📁 Service - Business logic 📁 Repository - Database interaction Example 👇 @RestController @RequestMapping("/users") public class UserController { @Autowired private UserService userService; @GetMapping("/{id}") public User getUser(@PathVariable Long id) { return userService.getUserById(id); } } 💡 Why this matters: ✔ Clean code ✔ Easy testing ✔ Better scalability ⚠️ Avoid: Putting everything inside controller ❌ Structure matters more than code 🔥 Follow for more practical backend tips 🚀 #SpringBoot #Java #CleanArchitecture #Backend
To view or add a comment, sign in
-
Spent 25 minutes wondering why my Spring Boot API was returning empty response The controller looked fine @GetMapping("/users") public List<User> getUsers() { return userService.findAll(); } Service was returning data when I debugged But the API response was always empty The problem was the User class had no getters Jackson needs getters to serialize objects to JSON No getters means no fields in the response The fix was adding @Data from Lombok One annotation and everything worked Spring Boot returned the data but Jackson could not read the fields without getters Ever had a bug that made you question everything #Java #SpringBoot #Jackson #Debugging #BackendDevelopment
To view or add a comment, sign in
-
Stop labeling your Spring Beans randomly! 🛑 I see many projects where @Component, @Service, and @Repository are used interchangeably. They all register a Bean in the context, so they are the same, right? Not exactly. Using the right stereotype is about Communication and Semantics. 🔹 @Service: Clearly states: "This is where the business logic lives." It's your domain's heart. 🔹 @Repository: Signals: "I talk to the database." Spring provides an extra layer of magic here: it automatically translates platform-specific exceptions (like SQLException) into Data Access Exceptions. 🔹 @Component: The generic catch-all. Use it for utility classes or anything that doesn't fit the service/repository pattern. Tip: Using the correct label makes your code readable for the next dev. It tells a story about what each class is responsible for before they even read a single line of implementation. How strict is your team with stereotyping their Spring components? Let’s talk below! 👇 #Java #SpringBoot #SoftwareArchitecture #CleanCode #Backend #SpringFramework #CleanDesign
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
AutoConfigurations: https://www.garudax.id/posts/muttahirislam_java-springboot-softwaredevelopment-share-7447349327124971520-iOid?utm_source=share&utm_medium=member_desktop&rcm=ACoAADwFR8oB8iMWjtSOMdoQy2FyK5ZJK9ZvtjU