💻 Understanding Spring Beans in Spring Framework As I continue learning Spring, I explored an important concept called Spring Beans. In Spring, a Bean is simply an object that is created, managed, and controlled by the Spring container. In my previous project, I used an Employee class, and Spring created its object using the configuration file. That object is called a Spring Bean. In simple terms: Instead of creating objects manually using new, Spring creates and manages them for us. 🔹 Key points about Spring Beans: ✔ Managed by Spring IoC container ✔ Defined using configuration (XML or annotations) ✔ Supports Dependency Injection ✔ Helps in building loosely coupled applications Understanding Beans helped me clearly see how Spring handles object creation and management internally. Continuing to explore more Spring concepts step by step 🚀 Github Link: -https://lnkd.in/dKrcejQw #Java #SpringFramework #SpringBeans #BackendDevelopment #LearningJourney
Deepak Kale’s Post
More Relevant Posts
-
🚀 30 Days of Spring Boot – Day 2 Today I explored one of the core foundations of Spring — Beans & Their Management. 🔹 What I learned: ✅ Spring Bean A Bean is a Java object managed by the Spring IoC container. Instead of creating objects using new, Spring handles creation, lifecycle, and dependency injection. ✅ @Bean Annotation Used to manually define a Bean inside a @Configuration class. It gives full control over object creation — especially useful for third-party classes or custom configurations. 💡 Even though we use new inside a @Bean method, it is executed only once by Spring (Singleton scope by default) and reused across the application. ✅ Bean Scope Defines how many instances Spring creates: Singleton → Single shared instance (default) Prototype → New instance every time Request → Per HTTP request Session → Per user session 🔥 Key Takeaway: “Write new once, let Spring manage and reuse the object everywhere.” 📌 Strengthening fundamentals step by step. #SpringBoot #Java #BackendDevelopment #LearningJourney #100DaysOfCode #Microservices
To view or add a comment, sign in
-
Understanding @Entity in Spring Boot In Spring Boot, working with databases is a common task. One important annotation used for this is: @Entity But what does it actually do? @Entity is used to mark a class as a JPA entity, which means it will be mapped to a database table. Key Points: 🔹 Each class annotated with @Entity represents a table in the database 🔹 Each object of that class represents a row in the table 🔹 Fields in the class are mapped to columns Commonly used with: • @Id → Defines the primary key • @GeneratedValue → Auto-generates values (like IDs) • @Column → Customizes column mapping In simple terms: @Entity → Class becomes Table Object → Row in table Understanding @Entity is important because it is the foundation of how Spring Boot interacts with databases. #SpringBoot #Java #BackendDevelopment
To view or add a comment, sign in
-
While working on backend systems, I revisited some features from Java 17… and honestly, they make code much cleaner. One feature I find really useful is Records. 👉 Earlier: We used to write a lot of boilerplate just to create a simple data class. Getters Constructors toString(), equals(), hashCode() ✅ With Java 17 — Records: You can define a data class in one line: public record User(String name, int age) {} That’s it. Java automatically provides: ✔️ Constructor ✔️ Getters ✔️ equals() & hashCode() ✔️ toString() 💡 Practical usage: User user = new User("Dipesh", 25); System.out.println(user.name()); // Dipesh System.out.println(user.age()); // 25 🧠 Where this helps: DTOs in APIs Response objects Immutable data models What I like most is how it reduces boilerplate and keeps the code focused. Would love to know — are you using records in your projects? #Java #Java17 #Backend #SoftwareEngineering #Programming #Microservices #LearningInPublic
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
-
#Java #Spring #Bean 🌱 Spring Bean Lifecycle 👉 In Spring Framework, bean lifecycle has 5 simple steps: 🔄 Lifecycle Steps 1️⃣ Instantiate ➡️ Spring creates object 2️⃣ Inject Dependencies 💉 ➡️ Dependencies added (@Autowired) 3️⃣ Initialize ⚙️ ➡️ Setup using @PostConstruct 4️⃣ Use Bean 🚀 ➡️ Business logic runs 5️⃣ Destroy 🧨 ➡️ Cleanup using @PreDestroy 🧠 One-Line 👉 Spring Bean Lifecycle = Create → Inject → Initialize → Use → Destroy (managed by Spring Container)
To view or add a comment, sign in
-
Class 7 On the 7’s session with Armin M.took us deep into the world of Java Generics. We explored how to write flexible, reusable code while maintaining the strict type safety that robust enterprise systems require. Generic Type Safety at Compile Time: We learned how Generics act as a protective layer, catching type mismatches during compilation rather than letting them crash the application at runtime. Type Erasure: A deep dive into how the Java compiler handles Generics by erasing type parameters after compilation to maintain backward compatibility with older JVM versions. Array Type Safety at Runtime: Comparing how Arrays handle types differently than Generics. Unlike Generics, Arrays are reified, meaning they enforce their type checks while the program is running. Wildcards & Bounds (Extends vs. Super): We tackled the complexity of ? extends T, Upper Bound, and ? super T, Lower Bound, to allow for more flexible API designs. PECS (Producer Extends, Consumer Super): The golden rule for Generics. We learned that if you are pulling items out of a structure, it’s a Producer, extends; if you are putting items in, it’s a Consumer, super.
To view or add a comment, sign in
-
🚀 Day 11: Scope & Memory – Mastering Variable Types in Java 🧠📍 Today’s focus was on understanding where data lives in a program—a crucial step toward writing efficient and predictable code. In Java, the way a variable is declared directly impacts its scope, lifetime, and memory allocation. Here’s how I broke it down: 🔹 1. Local Variables – Temporary Workers ⏱️ • Declared inside methods • Accessible only within that method • Created when the method starts, destroyed when it ends • ⚠️ Must be initialized before use (no default values) 🔹 2. Instance Variables – Object Properties 🏠 • Declared inside a class, outside methods • Require an object to access • Each object gets its own copy • Changes in one object do NOT affect another 🔹 3. Static Variables – Shared Data 🌐 • Declared with the static keyword • Belong to the class, not objects • Accessed using the class name (no object needed) • Only one copy exists, shared across all instances 💡 Key Takeaway: Variable scope is more than just visibility—it’s about memory management and data control. Knowing where and how variables exist helps in building optimized and scalable applications. Step by step, I’m strengthening my foundation in Java and moving closer to writing production-level code. 💻 #JavaFullStack #CoreJava #CodingJourney #VariableScope #MemoryManagement #Day11 #LearningInPublic
To view or add a comment, sign in
-
Built an HTTP server from scratch in Java. No frameworks. No Netty. No Spring Boot. Just raw sockets, manual byte parsing, and a thread pool wired from the ground up. The goal was never to reinvent the wheel. It was to understand what the wheel is actually made of. What was built: → TCP socket listener handing connections to a fixed thread pool of 500 workers → HTTP/1.1 parser written byte-by-byte - request line, headers, body (JSON + form-urlencoded) → Router handling HEAD, GET and POST with static file serving and query param injection → Structured error responses for 400, 404, 500, 501, and 505 → WebRootHandler with path traversal protection → Full JUnit test suite, Maven build, SLF4J logging, and a Dockerized deployment What it reinforced: Networking - HTTP is just bytes on a wire. The kernel speaks TCP, not HTTP. The parser is what gives those bytes meaning. Operating systems - the boundary between user space and kernel space stopped being abstract. accept(), read(), write() are syscalls. Everything else lives in the JVM. Concurrency - 500 threads sharing a single handler. Statelessness stops being a design preference and becomes a correctness requirement. Docker - the container wraps the JVM, not the kernel. Syscalls go to the host kernel. There is no container kernel. Building something from scratch is one of the most honest ways to learn. Every assumption gets tested, every abstraction gets earned. A recommendation from Kashif Sohail turned into weeks of going deep on networking, OS internals, and concurrency. Grateful for that push. GitHub repo :https://lnkd.in/dxxjXxpt #Java #Networking #OperatingSystems #Backend #SystemsEngineering #Docker #OpenSource
To view or add a comment, sign in
-
-
🚀 Understanding Autowire byName in Spring In Spring Framework, Autowire byName is a type of automatic dependency injection where the container matches a bean with a property based on its name. 👉 In simple words: Spring looks for a bean whose id/name matches the variable name in your class. 🔹 How it works? ✔ Spring checks the property name ✔ Finds a bean with the same name ✔ Injects it automatically 🔹 Example: class Student { private Address address; public void setAddress(Address address) { this.address = address; } } <bean id="address" class="com.example.Address"/> <bean id="student" class="com.example.Student" autowire="byName"/> 👉 Here, the property name address matches the bean id address, so Spring injects it automatically. 🔹 Key Points ✔ Works only with setter methods ✔ Depends on matching names exactly ✔ Easy to use but less flexible than annotations 💡 Pro Tip: In modern Spring Boot, we mostly use @Autowired instead of XML-based autowiring. ✨ Understanding these basics helps you master Spring Dependency Injection! Anand Kumar Buddarapu #Java #SpringBoot #DependencyInjection #Autowiring #BackendDevelopment #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
Day-4 Spring Without XML. Today I explored how Spring works completely using annotations (no XML). - Started container using AnnotationConfigApplicationContext -Used @Configuration, @ComponentScan, @PropertySource -Created beans with @Component -Injected values using @Value -Managed dependencies using @Autowired ➡️ Final result: Fully initialized object with zero manual wiring. Clean. Simple. Powerful. git - https://lnkd.in/gwbUxRiK Frontlines EduTech (FLM) #SpringFramework #Java #BackendDevelopment #LearningInPublic #100DaysOfCode
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