<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Writetorushikesh on Medium]]></title>
        <description><![CDATA[Stories by Writetorushikesh on Medium]]></description>
        <link>https://medium.com/@writetorushikesh?source=rss-56311319ed5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Writetorushikesh on Medium</title>
            <link>https://medium.com/@writetorushikesh?source=rss-56311319ed5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:35:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@writetorushikesh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Apache Kafka: Beginner’s Guide]]></title>
            <link>https://medium.com/@writetorushikesh/apache-kafka-beginners-guide-0167691fba33?source=rss-56311319ed5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0167691fba33</guid>
            <category><![CDATA[apache-kafka]]></category>
            <dc:creator><![CDATA[Writetorushikesh]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 13:03:53 GMT</pubDate>
            <atom:updated>2025-02-15T13:03:53.521Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction to Kafka</strong></p><p>Apache Kafka is a distributed, high-throughput, fault-tolerant event streaming platform. It is designed to handle real-time data feeds efficiently. Kafka is often used for building data pipelines, real-time analytics, event-driven applications, and stream processing systems.</p><p><strong>Core Concepts</strong></p><p><strong>1. Topics</strong></p><p>• A topic is a category or feed name where messages are sent by producers.</p><p>• Kafka topics are <strong>log-structured</strong>. They store data in an append-only format, ensuring immutability of written messages.</p><p>• <strong>Partitions</strong>: A topic can be broken down into multiple partitions, each storing a subset of the topic’s data. Every message within a partition has a unique <strong>offset</strong>.</p><p>Example:</p><p><strong>Topic</strong>: Orders</p><p><strong>Partitions</strong>: Orders-0, Orders-1, Orders-2</p><p><strong>Key Points</strong>:</p><p>• Partitioning allows Kafka to scale horizontally by distributing partitions across multiple brokers.</p><p>• Each partition is replicated for fault tolerance.</p><p><strong>2. Messages</strong></p><p>• A message is the smallest unit of data sent to Kafka.</p><p>• It consists of:</p><p>• <strong>Key</strong> (optional): Used for determining the partition.</p><p>• <strong>Value</strong>: The actual data (e.g., JSON, string, binary, etc.).</p><p>• <strong>Timestamp</strong>: When the message was produced.</p><p><strong>3. Producers</strong></p><p>• Producers publish messages to Kafka topics.</p><p>• They determine which partition a message is sent to based on a <strong>partitioning strategy</strong>:</p><p>• <strong>Round-robin</strong> (default when no key is provided).</p><p>• <strong>Hashing</strong> (if a key is provided).</p><p>• Custom partitioners.</p><p><strong>4. Consumers</strong></p><p>• Consumers read messages from Kafka topics.</p><p>• Kafka allows consumers to be part of a <strong>consumer group</strong>, which ensures load balancing:</p><p>• Within a group, each partition is assigned to only one consumer.</p><p>• If a consumer fails, the partitions it was handling are reassigned to another consumer.</p><p><strong>5. Brokers</strong></p><p>• Kafka brokers are servers that store and manage topic partitions.</p><p>• Each broker is responsible for storing data for its assigned partitions.</p><p>• Brokers handle client requests to read/write messages.</p><p><strong>Broker Responsibilities</strong>:</p><p>• Serve partition leaders.</p><p>• Replicate partitions for fault tolerance.</p><p><strong>6. Replication</strong></p><p>• Kafka replicates partitions across multiple brokers for durability.</p><p>• One broker is the <strong>leader</strong> for each partition, and the others are <strong>followers</strong>.</p><p>• Followers replicate data from the leader.</p><p>• Kafka uses the <strong>In-Sync Replica (ISR)</strong> list to keep track of replicas that are fully up-to-date.</p><p><strong>7. Controller</strong></p><p>• The Kafka <strong>controller</strong> manages partition leadership, broker states, and replica assignments.</p><p>• It is responsible for electing partition leaders when brokers fail.</p><p>• In newer Kafka versions, <strong>KRaft</strong> (Kafka Raft) mode replaces ZooKeeper with a built-in controller quorum.</p><p><strong>8. ZooKeeper (Legacy)</strong></p><p>• Used for:</p><p>• Metadata storage.</p><p>• Leader election.</p><p>• Broker state tracking.</p><p><strong>Note:</strong> Kafka is moving to KRaft mode to eliminate the need for ZooKeeper.</p><p><strong>Kafka Architecture Flow</strong></p><p>1. <strong>Producer</strong> sends data to a Kafka topic.</p><p>2. Kafka broker appends the message to the correct partition (based on partitioning strategy).</p><p>3. Data is replicated to follower brokers for durability.</p><p>4. <strong>Consumers</strong> pull messages from partitions and process them in order.</p><p><strong>Important Kafka Concepts</strong></p><p><strong>Durability</strong></p><p>• Messages are written to disk for durability.</p><p>• Configurable data retention policies allow Kafka to store messages for a certain time or size limit.</p><p><strong>High Availability</strong></p><p>• Kafka ensures availability by replicating partitions across multiple brokers.</p><p>• If the leader broker for a partition fails, a new leader is chosen from the ISR list.</p><p><strong>Data Consistency</strong></p><p>• Only messages that have been successfully replicated are exposed to consumers (depending on configuration).</p><p><strong>Kafka Configuration Basics</strong></p><p><strong>Producer Acknowledgments (acks)</strong></p><p>• <strong>acks=0</strong>: Producer doesn’t wait for acknowledgment (fast, but risky).</p><p>• <strong>acks=1</strong>: Waits for leader acknowledgment (balance between durability and speed).</p><p>• <strong>acks=all</strong>: Waits for all ISR replicas to acknowledge (most durable, but slower).</p><p><strong>Consumer Offset Management</strong></p><p>• Kafka tracks the offset of the last consumed message.</p><p>• Consumers can commit offsets manually or automatically.</p><p><strong>Kafka Deployment Considerations</strong></p><p><strong>1. Replication Factor</strong></p><p>Set to at least 3 for fault tolerance (ensures data survives broker failures).</p><p><strong>2. Partitioning Strategy</strong></p><p>Partitioning should align with data access patterns to ensure even distribution of workload.</p><p><strong>3. Retention Policies</strong></p><p>Define how long Kafka retains messages (e.g., 7 days or 100GB per topic).</p><p><strong>4. Security</strong></p><p>• <strong>TLS Encryption</strong>: Secure communication.</p><p>• <strong>Authentication</strong>: Use SASL (Simple Authentication and Security Layer).</p><p>• <strong>Authorization</strong>: Control access to topics and brokers.</p><p><strong>Key Kafka APIs</strong></p><p>1. <strong>Producer API</strong>: Allows apps to publish messages to Kafka topics.</p><p>2. <strong>Consumer API</strong>: Enables apps to consume messages from Kafka.</p><p>3. <strong>Streams API</strong>: Provides stream processing capabilities for real-time data transformation.</p><p>4. <strong>Connect API</strong>: Integrates Kafka with external systems (databases, file systems).</p><p><strong>Kafka Example Use Cases</strong></p><p>1. <strong>Real-Time Analytics</strong></p><p>Stream event data (e.g., clickstream) for real-time analysis.</p><p>2. <strong>Log Aggregation</strong></p><p>Collect logs from different sources and store them in Kafka for analysis or processing.</p><p>3. <strong>Data Pipelines</strong></p><p>Move data between services, databases, or storage systems with Kafka acting as a data buffer.</p><p>4. <strong>Event Sourcing</strong></p><p>Capture state changes as an immutable sequence of events for replayability and debugging.</p><p><strong>Basic Kafka Commands</strong></p><p>1. <strong>Start a Kafka Broker (Local)</strong></p><p>bin/kafka-server-start.sh config/server.properties</p><p>2. <strong>Create a Topic</strong></p><p>bin/kafka-topics.sh — create — topic my-topic — bootstrap-server localhost:9092 — partitions 3 — replication-factor 1</p><p>3. <strong>List Topics</strong></p><p>bin/kafka-topics.sh — list — bootstrap-server localhost:9092</p><p>4. <strong>Produce Messages</strong></p><p>bin/kafka-console-producer.sh — topic my-topic — bootstrap-server localhost:9092</p><p>5. <strong>Consume Messages</strong></p><p>bin/kafka-console-consumer.sh — topic my-topic — bootstrap-server localhost:9092 — from-beginning</p><p><strong>Kafka Best Practices</strong></p><p>1. <strong>Monitor Broker Health</strong></p><p>Use monitoring tools to track broker performance and detect failures.</p><p>2. <strong>Optimize Partitioning</strong></p><p>Ensure partitions are distributed evenly across brokers to avoid bottlenecks.</p><p>3. <strong>Data Retention</strong></p><p>Set appropriate retention policies to avoid excessive storage usage.</p><p>4. <strong>Consumer Lag Management</strong></p><p>Track consumer lag to ensure real-time data processing.</p><p><strong>Next Steps</strong></p><p>• Explore advanced features like Kafka Streams for stream processing.</p><p>• Set up Kafka Connect to integrate with databases or cloud services.</p><p>• Practice building resilient Kafka applications with replication and fault tolerance in mind.</p><p>This beginner’s guide provides a solid foundation for understanding Kafka’s architecture and core concepts. Let me know if you’d like more details on any specific topic!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0167691fba33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[what are addition benefits of protobuf]]></title>
            <link>https://medium.com/@writetorushikesh/what-are-addition-benefits-of-protobuf-0e501d563e90?source=rss-56311319ed5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e501d563e90</guid>
            <category><![CDATA[protobuf]]></category>
            <dc:creator><![CDATA[Writetorushikesh]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 11:09:26 GMT</pubDate>
            <atom:updated>2024-04-23T11:09:26.801Z</atom:updated>
            <content:encoded><![CDATA[<p>Besides the core functionality of efficiently serializing and deserializing structured data, protocol buffers (protobuf) offer several additional benefits:</p><p>Efficiency:</p><ul><li>Compact Binary Format: Protobuf serializes data into a binary format, which is more compact compared to text-based formats like JSON or XML. This leads to smaller message sizes, reducing bandwidth usage and storage requirements.</li><li>Efficient Encoding: Protobuf uses efficient encoding schemes for integers and other data types, further reducing message size.</li></ul><p>Performance:</p><ul><li>Faster Serialization/Deserialization: Because of its binary format and efficient encoding, protobuf provides faster serialization and deserialization compared to text-based formats. This results in improved performance, especially in high-throughput systems.</li><li>Code Generation: Generated code provides direct access to fields, eliminating the need for runtime reflection and improving performance.</li></ul><p>Language and Platform Neutrality:</p><ul><li>Cross-Platform Support: Protobuf supports multiple programming languages, allowing communication between systems written in different languages.</li><li>Language Integration: Generated code is idiomatic to the target language, providing a natural interface for developers.</li></ul><p>Schema Evolution:</p><ul><li>Forward and Backward Compatibility: Protobuf supports schema evolution, allowing you to add, remove, or modify fields without breaking compatibility with older versions of the schema. This is crucial for evolving systems over time.</li><li>Versioning: Protobuf messages can include versioning information, facilitating backward and forward compatibility checks.</li></ul><p>Documentation and Readability:</p><ul><li>Self-Describing Format: Protobuf messages are self-describing. Each field in a message is identified by a unique tag, and the field’s type is explicitly defined. This improves readability and helps in understanding message structures.</li><li>Comments and Documentation: Protobuf allows comments in .proto files, enabling developers to document message structures effectively.</li></ul><p>Data Validation:</p><ul><li>Defined Data Types: Protobuf defines a set of primitive data types (integers, floats, strings, etc.), ensuring data consistency and type safety.</li><li>Field Constraints: You can define field constraints such as required, optional, or repeated fields, ensuring data integrity.</li></ul><p>Integration with RPC Frameworks:</p><ul><li>gRPC: Protobuf is tightly integrated with gRPC, a high-performance RPC framework. gRPC uses protobuf for defining service APIs and serializing messages.</li></ul><p>Extensibility:</p><ul><li>Custom Options: Protobuf allows you to define custom options and extensions, providing flexibility to tailor protobuf to your specific needs.</li><li>Custom Code Generators: You can write custom code generators to generate code in other languages or formats.</li></ul><p>Security:</p><ul><li>Binary Format: The binary format used by protobuf can be more secure than text-based formats, as it’s less susceptible to injection attacks.</li></ul><p>Overall, Protocol Buffers offer a powerful and efficient way to serialize and deserialize data, with additional benefits such as performance, language neutrality, schema evolution, and extensibility, making it a popular choice for communication between distributed systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e501d563e90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Dependency Injection and Bean Creation in Spring]]></title>
            <link>https://medium.com/@writetorushikesh/understanding-dependency-injection-and-bean-creation-in-spring-f1e46a0aa6c2?source=rss-56311319ed5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1e46a0aa6c2</guid>
            <dc:creator><![CDATA[Writetorushikesh]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 12:32:54 GMT</pubDate>
            <atom:updated>2023-11-01T12:32:54.791Z</atom:updated>
            <content:encoded><![CDATA[<p>Dependency injection (DI) and bean management are fundamental concepts in the Spring framework. They play a crucial role in achieving loose coupling, modularity, and maintainability in your applications. In this article, we’ll delve into what dependency injection is, why it’s important, and how beans are created and managed in Spring.</p><p>Table of Contents</p><p>1. [Introduction to Dependency Injection](#introduction-to-dependency-injection)<br>2. [Creating Beans in Spring](#creating-beans-in-spring)<br>3. [When to Use Which Method](#when-to-use-which-method)<br>4. [Summary and Conclusion](#summary-and-conclusion)</p><p>— -</p><p><strong>##<em> Introduction to Dependency Injection</em></strong></p><p><strong>Dependency injection (DI)</strong> is a design pattern in software development that promotes loose coupling between components in a system. It involves passing dependencies (e.g., objects, services) as parameters rather than hardcoding them within a class. This makes your code more modular, maintainable, and testable.</p><p>In Spring, dependency injection is a core principle. It’s achieved through the Spring container, which manages the lifecycle of beans and handles the injection of dependencies.</p><p>— -</p><h4><strong><em>Creating Beans in Spring</em></strong></h4><p>In Spring, a <strong>bean </strong>is a managed object that is created, configured, and assembled by the Spring container. There are several methods to create beans, each with its own use cases and advantages.</p><p>### 1. Using Annotations</p><p>Annotations like `<a href="http://twitter.com/Component">@Component</a>`, `<a href="http://twitter.com/Service">@Service</a>`, `<a href="http://twitter.com/Repository">@Repository</a>`, and `<a href="http://twitter.com/Controller">@Controller</a>` are used to mark classes as Spring-managed components. The Spring container automatically detects and manages these beans.</p><p>Example:</p><p>```java<br><a href="http://twitter.com/Service">@Service</a><br>public class UserService {<br> // …<br>}<br>```</p><p>### 2. Java Configuration</p><p>Using Java or Kotlin configuration classes, you can define beans using the `<a href="http://twitter.com/Configuration">@Configuration</a>` and `<a href="http://twitter.com/Bean">@Bean</a>` annotations. This approach provides type safety and allows for programmatic bean creation.</p><p>Example (Kotlin):</p><p>```kotlin<br><a href="http://twitter.com/Configuration">@Configuration</a><br>class AppConfig {</p><p><a href="http://twitter.com/Bean">@Bean</a><br> fun userRepository(): UserRepository {<br> return DatabaseUserRepository()<br> }</p><p><a href="http://twitter.com/Bean">@Bean</a><br> fun userService(userRepository: UserRepository): UserService {<br> return UserService(userRepository)<br> }<br>}<br>```</p><p>### 3. Component Scanning</p><p>Spring can automatically detect classes with certain annotations (e.g., `<a href="http://twitter.com/Component">@Component</a>`) and create beans for them. This is known as **component scanning**. It’s useful for convention-based projects.</p><p>Example:</p><p>```java<br><a href="http://twitter.com/Component">@Component</a><br>public class DatabaseUserRepository implements UserRepository {<br> // …<br>}<br>```</p><p>### 4. Factory Method</p><p>You can use a factory method to create and configure a bean. This approach is useful when you need to perform complex logic to create an instance of a bean.</p><p>Example:</p><p>```java<br>public class BeanFactory {<br> public static UserService createUserService() {<br> UserRepository userRepository = new DatabaseUserRepository();<br> return new UserService(userRepository);<br> }<br>}<br>```</p><p>### 5. Using `<a href="http://twitter.com/ComponentScan">@ComponentScan</a>`</p><p>By adding `<a href="http://twitter.com/ComponentScan">@ComponentScan</a>` to your configuration class, you can fine-tune component scanning behavior if needed. It allows you to specify additional packages or customize scanning filters.</p><p>Example:</p><p>```java<br><a href="http://twitter.com/Configuration">@Configuration</a><br><a href="http://twitter.com/ComponentScan">@ComponentScan</a>(basePackages = “com.example”)<br>public class AppConfig {<br> // …<br>}<br>```</p><p>### 6. Stereotype Annotations</p><p>Annotations like `<a href="http://twitter.com/Component">@Component</a>`, `<a href="http://twitter.com/Service">@Service</a>`, `<a href="http://twitter.com/Repository">@Repository</a>`, and `<a href="http://twitter.com/Controller">@Controller</a>` serve as markers for classes that should be managed as beans. They are widely used in modern Spring applications.</p><p>Example:</p><p>```java<br><a href="http://twitter.com/Service">@Service</a><br>public class UserService {<br> // …<br>}<br>```</p><p>— -</p><p>## When to Use Which Method</p><p>- **XML Configuration**:<br> — Use when working with legacy projects or non-code configurations.<br> — Consider if you need to work with configurations provided externally.</p><p>- **Java/Kotlin Configuration**:<br> — Ideal for modern Spring applications for strong type safety and better IDE support.<br> — Provides a natural and type-safe way to define beans.</p><p>- **Component Scanning**:<br> — Suitable for convention over configuration projects.<br> — Use when you have control over package structure and class naming conventions.</p><p>- **Factory Method**:<br> — Use when you need complex logic to create an instance of a bean.<br> — Appropriate when you need to create an object using a method not on the bean itself.</p><p>- **Using `<a href="http://twitter.com/ComponentScan">@ComponentScan</a>`**:<br> — Use to fine-tune component scanning behavior.<br> — Allows you to specify additional packages or customize scanning filters.</p><p>- **Stereotype Annotations**:<br> — Use when you want to leverage Spring’s automatic bean detection and wiring capabilities.<br> — Suitable for building modular applications with well-defined components.</p><p>— -</p><p>## Summary and Conclusion</p><p>Dependency injection and bean management are core concepts in Spring, enabling flexible, modular, and maintainable code. By understanding various methods of creating beans and when to use each approach, you can effectively design and develop Spring applications. Whether you prefer XML configuration, Java/Kotlin configuration, or component scanning, Spring provides versatile tools to suit your project’s needs. Choose the method that best aligns with your application’s requirements and development style. With Spring, you have the flexibility to create beans in a way that works best for you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1e46a0aa6c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The most commonly used annotations in the Spring framework and their purposes:]]></title>
            <link>https://medium.com/@writetorushikesh/the-most-commonly-used-annotations-in-the-spring-framework-and-their-purposes-2ec199cf13c9?source=rss-56311319ed5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ec199cf13c9</guid>
            <dc:creator><![CDATA[Writetorushikesh]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 12:00:57 GMT</pubDate>
            <atom:updated>2023-11-01T12:00:57.916Z</atom:updated>
            <content:encoded><![CDATA[<p>1. @Component:</p><p>Purpose: Marks a class as a Spring-managed component. It is a generic stereotype annotation for any Spring-managed component.</p><p>Usage: Typically used when the role of a class in the application is not clear or when a more specific stereotype annotation is not appropriate.</p><p>2. @Service:</p><p>Purpose: Indicates that a class is a service in the application. Services typically contain business logic and perform operations related to a specific domain in the application.</p><p>Usage: Used to mark classes that handle business logic and operations.</p><p>3. @Repository:</p><p>Purpose: Indicates that a class is a repository, typically responsible for data access and storage operations. It is often used in conjunction with Spring’s data access technologies, like Spring Data JPA.</p><p>Usage: Used to mark classes responsible for data access and storage.</p><p>4. @Controller:</p><p>Purpose: Marks a class as a controller in a Spring MVC application. Controllers handle HTTP requests, process them, and return an appropriate response, often by invoking services or repositories.</p><p>Usage: Used to mark classes responsible for handling HTTP requests.</p><p>5. @RestController:</p><p>Purpose: Combines the `@Controller` and `@ResponseBody` annotations. It is used to mark a class that handles HTTP requests and returns the response directly in the form of JSON or XML (typically used for RESTful APIs).</p><p>Usage: Used when you want to create a RESTful controller.</p><p>6. @RequestMapping:</p><p>Purpose: Maps HTTP requests to specific methods or handlers within a controller. It is used to define the URL patterns that a controller should handle.</p><p>Usage: Applied to methods or classes to specify the URL mappings.</p><p>7. @Autowired:</p><p>Purpose: Indicates that a class field, setter method, or constructor should be automatically wired by Spring with a matching bean from the Spring container.</p><p>Usage: Used for dependency injection.</p><p>8. @Value:</p><p>Purpose: injects a value into a variable or method parameter.</p><p>Usage: Used for injecting properties or values from configuration files.</p><p>9. @Qualifier:</p><p>Purpose: Helps disambiguate which bean should be injected when there are multiple beans of the same type in the spring container.</p><p>Usage: Used in conjunction with `@Autowired`.</p><p>10. @Configuration:</p><p>Purpose: Indicates that a class contains bean definitions and configuration for the application. It is used in combination with `@Bean` methods.</p><p>Usage: Used to define configuration classes.</p><p>11. @Bean:</p><p>Purpose: Indicates that a method produces a bean to be managed by the Spring container.</p><p>Usage: Used in a configuration class to declare methods that create and configure beans.</p><p>12. @Primary:</p><p>Purpose: Indicates that if multiple beans of the same type exist, the one annotated with `@Primary` should be preferred for injection.</p><p>Usage: Used to specify a primary bean when there are multiple candidates.</p><p>These are some of the most commonly used annotations in the Spring framework. Each annotation serves a specific purpose and plays a crucial role in defining the structure and behavior of your Spring application.</p><p>Certainly! Below are examples of each of the commonly used Spring annotations:</p><p>1. @Component</p><pre>@Component<br>public class ExampleComponent {<br>// …<br>}</pre><p>2. @Service</p><pre>@Service<br>public class ExampleService {<br>// …<br>}</pre><p>3. @Repository</p><pre>@Repository<br>public class ExampleRepository {<br>// …<br>}</pre><p>4. @Controller</p><pre>@Controller<br>public class ExampleController {<br>@GetMapping(&quot;/example&quot;)<br>public String handleRequest() {<br>// Handle the request<br>return &quot;exampleView&quot;;<br>}<br>}</pre><p>5. @RestController</p><pre>@RestController<br>public class ExampleRestController {<br>@GetMapping(&quot;/api/example&quot;)<br>public String handleApiRequest() {<br>return &quot;Hello, this is an API response!&quot;;<br>}<br>}</pre><p>6. @RequestMapping</p><pre>@Controller<br>@RequestMapping(&quot;/example&quot;)<br>public class ExampleController {<br>@GetMapping(&quot;/page&quot;)<br>public String handleRequest() {<br>// Handle the request<br>return &quot;exampleView&quot;;<br>}<br>}</pre><p>7. @Autowired</p><pre>@Service<br>public class ExampleService {<br>@Autowired<br>private ExampleRepository repository;<br>// …<br>}</pre><p>8. @Value</p><pre>@Service<br>public class ExampleService {<br>@Value(&quot;${example.property}&quot;)<br>private String propertyValue;<br>// …<br>}</pre><p>9. @Qualifier</p><pre>@Service<br>public class ExampleService {<br>@Autowired<br>@Qualifier(&quot;specificImplementation&quot;)<br>private ExampleInterface example;<br>// …<br>}</pre><p>10. @Configuration and @Bean</p><pre>@Configuration<br>public class AppConfig {<br>@Bean<br>public ExampleService exampleService() {<br>return new ExampleService();<br>}<br>}</pre><p>11. @Primary</p><pre>@Component<br>@Primary<br>public class PrimaryExample implements ExampleInterface {<br>// …<br>}<br>@Component<br>public class SecondaryExample implements ExampleInterface {<br>// …<br>}<br>@Service<br>public class ExampleService {<br>@Autowired<br>private ExampleInterface example;<br>// …<br>}</pre><p>These examples demonstrate how each of these annotations is typically used in Spring applications. Keep in mind that these are simplified examples for illustration purposes, and real-world applications will likely have more complex configurations and logic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ec199cf13c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>