<?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 Roshan Farakate on Medium]]></title>
        <description><![CDATA[Stories by Roshan Farakate on Medium]]></description>
        <link>https://medium.com/@roshanfarakate?source=rss-518c63b10c4d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KW2L7lglSApVaQTN</url>
            <title>Stories by Roshan Farakate on Medium</title>
            <link>https://medium.com/@roshanfarakate?source=rss-518c63b10c4d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:01:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roshanfarakate/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[Global Exception Handling in Spring Boot]]></title>
            <link>https://medium.com/@roshanfarakate/global-exception-handling-in-spring-boot-712593159a26?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/712593159a26</guid>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 16:18:40 GMT</pubDate>
            <atom:updated>2025-08-25T16:18:40.215Z</atom:updated>
            <content:encoded><![CDATA[<p>Exception handling is a <strong>critical part of any Spring Boot application</strong>. Instead of cluttering controllers with try-catch blocks, Spring Boot provides a clean and centralized way to handle exceptions globally using a combination of <strong>annotations</strong>.</p><h3>Why Global Exception Handling?</h3><ul><li>Centralizes error-handling logic.</li><li>Makes code more <strong>readable and maintainable</strong>.</li><li>Returns <strong>consistent error responses</strong> (useful for REST APIs).</li><li>Decouples business logic from error-handling logic.</li></ul><h3>@ControllerAdvice</h3><ul><li>Declares a <strong>global exception handler</strong> across multiple controllers.</li><li>Works like an <strong>interceptor</strong> for exceptions thrown by methods annotated with @RequestMapping and related mapping annotations.</li></ul><pre>@ControllerAdvice<br>public class GlobalExceptionHandler {<br>    // Exception handlers go here<br>}</pre><p><strong>Key Points:</strong></p><ul><li>Scans all controllers and applies exception handling automatically.</li><li>Works in both <strong>MVC applications</strong> (returning views) and <strong>REST APIs</strong> (returning JSON/XML).</li></ul><h3>@RestControllerAdvice</h3><ul><li>A specialization of @ControllerAdvice + @ResponseBody.</li><li>Ensures that the response is always <strong>JSON/XML</strong> (instead of rendering a view).</li><li>Perfect for <strong>RESTful APIs</strong>.</li></ul><pre>@RestControllerAdvice<br>public class RestExceptionHandler {<br>    @ExceptionHandler(ResourceNotFoundException.class)<br>    public ResponseEntity&lt;String&gt; handleResourceNotFound(ResourceNotFoundException ex) {<br>        return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getMessage());<br>    }<br>}</pre><h3>@ExceptionHandler</h3><ul><li>Used inside @ControllerAdvice (or inside a controller itself).</li><li>Specifies the <strong>exception class</strong> to handle.</li><li>Catches exceptions thrown in controllers and returns a custom response.</li></ul><pre>@ExceptionHandler(IllegalArgumentException.class)<br>public ResponseEntity&lt;String&gt; handleIllegalArgument(IllegalArgumentException ex) {<br>    return ResponseEntity.badRequest().body(&quot;Invalid input: &quot; + ex.getMessage());<br>}</pre><p><strong>Key Points</strong></p><ul><li>Can handle <strong>one or multiple exceptions</strong>:</li></ul><pre>@ExceptionHandler({NullPointerException.class, IllegalStateException.class})</pre><ul><li>Can return ResponseEntity, custom objects, or even view names (in MVC).</li></ul><h3>@ResponseStatus</h3><ul><li>Maps an exception to a specific <strong>HTTP status code</strong>.</li><li>Can be used on <strong>custom exception classes</strong>.</li></ul><pre>@ResponseStatus(HttpStatus.NOT_FOUND)<br>public class ResourceNotFoundException extends RuntimeException {<br>    public ResourceNotFoundException(String message) {<br>        super(message);<br>    }<br>}</pre><p><strong>Key Points</strong></p><ul><li>Automatically sets the response status whenever the exception is thrown.</li><li>Great for <strong>simple exceptions</strong> (like 404 Not Found, 400 Bad Request).</li><li>Can be combined with @ControllerAdvice for detailed responses.</li></ul><h4>Example: Centralized Exception Handling in REST API</h4><pre>@RestControllerAdvice<br>public class GlobalExceptionHandler {<br><br>    @ExceptionHandler(ResourceNotFoundException.class)<br>    public ResponseEntity&lt;Map&lt;String, Object&gt;&gt; handleNotFound(ResourceNotFoundException ex) {<br>        Map&lt;String, Object&gt; response = new HashMap&lt;&gt;();<br>        response.put(&quot;error&quot;, &quot;Not Found&quot;);<br>        response.put(&quot;message&quot;, ex.getMessage());<br>        response.put(&quot;status&quot;, HttpStatus.NOT_FOUND.value());<br>        response.put(&quot;timestamp&quot;, LocalDateTime.now());<br>        return new ResponseEntity&lt;&gt;(response, HttpStatus.NOT_FOUND);<br>    }<br><br>    @ExceptionHandler(Exception.class) // fallback for all exceptions<br>    public ResponseEntity&lt;Map&lt;String, Object&gt;&gt; handleGeneral(Exception ex) {<br>        Map&lt;String, Object&gt; response = new HashMap&lt;&gt;();<br>        response.put(&quot;error&quot;, &quot;Internal Server Error&quot;);<br>        response.put(&quot;message&quot;, ex.getMessage());<br>        response.put(&quot;status&quot;, HttpStatus.INTERNAL_SERVER_ERROR.value());<br>        response.put(&quot;timestamp&quot;, LocalDateTime.now());<br>        return new ResponseEntity&lt;&gt;(response, HttpStatus.INTERNAL_SERVER_ERROR);<br>    }<br>}</pre><p>This ensures <strong>all controllers</strong> return a structured error response.</p><h3>Best Practices</h3><ul><li>Always include useful fields in error responses: timestamp, status, error, message, path (optional: request URI)</li><li>Use <strong>custom exception classes</strong> for clarity.</li><li>Use @ResponseStatus for <strong>simple exceptions</strong>.</li><li>Use @RestControllerAdvice for <strong>REST APIs</strong>.</li><li>Keep fallback @ExceptionHandler(Exception.class) for <strong>unexpected errors</strong>.</li></ul><h3>Interview Tips</h3><ul><li><em>Q: What’s the difference between </em><em>@ControllerAdvice and </em><em>@RestControllerAdvice?</em><br> -&gt; @RestControllerAdvice = @ControllerAdvice + @ResponseBody (returns JSON directly).</li><li><em>Q: Why use global exception handling instead of try-catch?</em><br> -&gt; Centralization, cleaner code, consistency.</li><li><em>Q: Can you handle multiple exceptions in one handler?</em><br> -&gt; Yes, use @ExceptionHandler({Ex1.class, Ex2.class}).</li><li><em>Q: How do you map a custom exception to HTTP 404?</em><br> -&gt; Annotate exception class with @ResponseStatus(HttpStatus.NOT_FOUND) or handle it in @ExceptionHandler.</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=712593159a26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Validation Annotations in Spring Boot]]></title>
            <link>https://medium.com/@roshanfarakate/validation-annotations-in-spring-boot-8e12995a110c?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e12995a110c</guid>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[java-annotations]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 16:02:59 GMT</pubDate>
            <atom:updated>2025-08-25T16:02:59.046Z</atom:updated>
            <content:encoded><![CDATA[<p>Validation plays a crucial role in modern web applications. Whenever users submit data through forms, APIs, or request payloads, developers must ensure the input meets certain rules (e.g., an email must be valid, age cannot be negative, names cannot be blank, etc.).</p><h3><strong>Commonly Used Validation Annotations:</strong></h3><h3>@NotNull</h3><ul><li>Ensures the value is not null.</li><li>Does not check for empty strings or collections.</li></ul><pre>@NotNull(message = &quot;Username cannot be null&quot;)<br>private String username;</pre><h3>@NotEmpty</h3><ul><li>Ensures the field is <strong>not null and not empty</strong>.</li><li>Works with strings, collections, and arrays.</li></ul><pre>@NotEmpty(message = &quot;Password cannot be empty&quot;)<br>private String password;</pre><h3>@NotBlank</h3><ul><li>Stronger version of @NotEmpty for strings.</li><li>Rejects null, empty (&quot;&quot;), and whitespace-only values (&quot; &quot;).</li></ul><pre>@NotBlank(message = &quot;Email is required&quot;)<br>private String email;</pre><h3>@Size(min, max)</h3><ul><li>Checks the length (for strings) or size (for collections/arrays).</li></ul><pre>@Size(min = 3, max = 20, message = &quot;Username must be between 3 and 20 characters&quot;)<br>private String username;</pre><h3>@Min and @Max</h3><ul><li>Ensures numeric values fall within a range.</li></ul><pre>@Min(value = 18, message = &quot;Age must be at least 18&quot;)<br>@Max(value = 60, message = &quot;Age must not exceed 60&quot;)<br>private int age;</pre><h3>@Positive / @PositiveOrZero</h3><ul><li>Ensures a number is strictly positive or ≥ 0.</li></ul><pre>@Positive(message = &quot;Salary must be positive&quot;)<br>private double salary;</pre><h3>@Negative / @NegativeOrZero</h3><ul><li>Opposite of positive.</li></ul><pre>@NegativeOrZero(message = &quot;Debt must be zero or negative&quot;)<br>private int debt;</pre><h3>@Email</h3><ul><li>Ensures the value is a valid email address.</li></ul><pre>@Email(message = &quot;Email should be valid&quot;)<br>private String email;</pre><h3>@Pattern</h3><ul><li>Validates string against a <strong>regular expression</strong>.</li></ul><pre>@Pattern(regexp = &quot;^[A-Za-z0-9]+$&quot;, message = &quot;Username must be alphanumeric&quot;)<br>private String username;</pre><h3>@Future, @FutureOrPresent, @Past, @PastOrPresent</h3><ul><li>Validates dates relative to the current date.</li></ul><pre>@Future(message = &quot;Booking date must be in the future&quot;)<br>private LocalDate bookingDate;</pre><h3>@AssertTrue and @AssertFalse</h3><ul><li>Ensures boolean fields meet conditions.</li></ul><pre>@AssertTrue(message = &quot;You must accept terms and conditions&quot;)<br>private boolean acceptedTerms;</pre><h3>@Valid</h3><ul><li>Cascade validation to nested objects.</li></ul><pre>@Valid<br>private Address address;</pre><h3>Handling Validation Errors in Controller</h3><p>Spring Boot throws MethodArgumentNotValidException if validation fails. You can handle it with:</p><pre>@RestControllerAdvice<br>public class GlobalExceptionHandler {<br><br>    @ExceptionHandler(MethodArgumentNotValidException.class)<br>    public ResponseEntity&lt;Map&lt;String, String&gt;&gt; handleValidationExceptions(MethodArgumentNotValidException ex) {<br>        Map&lt;String, String&gt; errors = new HashMap&lt;&gt;();<br>        ex.getBindingResult().getFieldErrors().forEach(error -&gt;<br>            errors.put(error.getField(), error.getDefaultMessage()));<br>        return ResponseEntity.badRequest().body(errors);<br>    }<br>}</pre><p>This returns user-friendly error messages like:</p><pre>{<br>  &quot;username&quot;: &quot;Username must be between 3 and 20 characters&quot;,<br>  &quot;email&quot;: &quot;Email should be valid&quot;<br>}</pre><p><strong>Example DTO with Validation:</strong></p><pre>public class UserRequest {<br><br>    @NotBlank(message = &quot;Username cannot be blank&quot;)<br>    @Size(min = 3, max = 20)<br>    private String username;<br><br>    @NotBlank<br>    @Email<br>    private String email;<br><br>    @NotEmpty<br>    private String password;<br><br>    @Min(18)<br>    private int age;<br><br>    @Valid<br>    private Address address;<br>}</pre><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e12995a110c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot Utility Annotations]]></title>
            <link>https://medium.com/@roshanfarakate/spring-boot-utility-annotations-11ac247c0702?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/11ac247c0702</guid>
            <category><![CDATA[java-annotations]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java-spring-boot]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 16:02:27 GMT</pubDate>
            <atom:updated>2025-08-25T16:02:27.225Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Boot isn’t just about reducing boilerplate code — it also provides <strong>utility annotations</strong> that simplify configuration, scheduling, caching, profiling, and environment-specific behaviors.</p><h3>@EnableScheduling</h3><ul><li>Enables Spring’s task scheduling capability.</li></ul><pre>@SpringBootApplication<br>@EnableScheduling<br>public class SchedulerApp { }<br><br>@Component<br>class ReportTask {<br>    @Scheduled(fixedRate = 60000)<br>    public void generateReport() {<br>        System.out.println(&quot;Report generated every 60 seconds&quot;);<br>    }<br>}</pre><p><strong>Modes of </strong><strong>@Scheduled:</strong></p><ul><li>fixedRate = 5000 → Runs every 5 seconds regardless of method completion.</li><li>fixedDelay = 5000 → Runs 5 seconds <strong>after the previous task finishes</strong>.</li><li>cron = &quot;0 0 12 * * ?&quot; → Runs at 12 PM daily.</li></ul><h3>@Scheduled</h3><ul><li>Used along with @EnableScheduling to define actual tasks.</li></ul><pre>@Scheduled(cron = &quot;0 0 9 * * MON-FRI&quot;)<br>public void sendWeeklyMail() {<br>    System.out.println(&quot;Mail sent at 9 AM, Monday to Friday&quot;);<br>}</pre><h3>EnableCaching</h3><ul><li><strong>Purpose:</strong> Turns on Spring’s cache management.</li></ul><pre>@SpringBootApplication<br>@EnableCaching<br>public class CacheApp { }</pre><h4>Caching Annotations</h4><p><strong>@Cacheable</strong> → Caches method result. Read optimization.</p><pre>@Cacheable(&quot;users&quot;)<br>public User getUser(Long id) {<br>    System.out.println(&quot;Fetching from DB...&quot;);<br>    return repository.findById(id).get();<br>}</pre><p>First call hits DB, subsequent calls use cache.</p><ul><li><strong>@CachePut</strong> → Always executes method and updates cache.</li></ul><pre>@CachePut(value = &quot;users&quot;, key = &quot;#user.id&quot;)<br>public User updateUser(User user) {<br>    return repository.save(user);<br>}</pre><ul><li><strong>@CacheEvict</strong> → Removes entry from cache. Cleanup cache when data is stale.</li></ul><pre>@CacheEvict(value = &quot;users&quot;, key = &quot;#id&quot;)<br>public void deleteUser(Long id) {<br>    repository.deleteById(id);<br>}</pre><h3>@Profile</h3><ul><li>Activates beans only for specific environments (e.g., dev, test, prod).</li><li>Useful for environment-specific configurations.</li></ul><pre>@Service<br>@Profile(&quot;dev&quot;)<br>public class DevPaymentService implements PaymentService { ... }<br><br>@Service<br>@Profile(&quot;prod&quot;)<br>public class ProdPaymentService implements PaymentService { ... }<br>spring:<br>  profiles:<br>    active: dev</pre><p>Yaml File:</p><pre>spring:<br>  profiles:<br>    active: dev</pre><h3>@ConditionalOnProperty</h3><ul><li>Creates a bean only if a certain property is set.</li><li>Feature toggling, environment-specific bean loading.</li></ul><pre>@Service<br>@ConditionalOnProperty(name = &quot;feature.payment.enabled&quot;, havingValue = &quot;true&quot;)<br>public class PaymentFeature { }</pre><p>Yaml File:</p><pre>feature:<br>  payment:<br>    enabled: true</pre><ul><li>@Profile → switch entire bean per environment, where as @ConditionalOnProperty → toggle feature based on config flag.</li></ul><h3>@Lazy</h3><ul><li>Initializes bean only when it’s first used (not at app startup).</li><li>Useful for performance optimization and circular dependency issues.</li></ul><pre>@Service<br>@Lazy<br>public class HeavyService {<br>    public HeavyService() {<br>        System.out.println(&quot;Loaded only when called&quot;);<br>    }<br>}</pre><h3>@ConfigurationProperties</h3><ul><li><strong>Purpose:</strong> Binds external properties into a POJO.</li></ul><pre>@Component<br>@ConfigurationProperties(prefix = &quot;app&quot;)<br>public class AppConfig {<br>    private String name;<br>    private int timeout;<br>    // getters &amp; setters<br>}</pre><p>Yaml File:</p><pre>app:<br>  name: PaymentService<br>  timeout: 30</pre><ul><li>@Value injects single values, where as,@ConfigurationProperties maps a group of properties.</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11ac247c0702" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JPA & Database Annotations in Spring Boot]]></title>
            <link>https://medium.com/@roshanfarakate/jpa-database-annotations-in-spring-boot-a5cbe1fe4e93?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5cbe1fe4e93</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[java-annotations]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 14:05:22 GMT</pubDate>
            <atom:updated>2025-08-22T14:05:22.933Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Boot heavily uses <strong>JPA (Java Persistence API)</strong> annotations for ORM (Object Relational Mapping). These annotations help map <strong>Java classes to database tables</strong> and define relationships, queries, and behaviors.</p><h3>@Entity</h3><ul><li>Marks a class as a JPA entity (a table in DB).</li><li>Must have a no-arg constructor.</li><li>Must have an identifier field (usually annotated with @Id).</li><li>Without @Entity, Hibernate won’t treat the class as persistent.</li></ul><pre>@Entity<br>public class Employee {<br>    @Id<br>    private Long id;<br>    private String name;<br>}</pre><h3>@Table</h3><ul><li><strong>Purpose:</strong> Maps an entity to a specific table.</li><li>Useful when class name ≠ table name.</li><li>Can define schema, unique constraints, indexes.</li><li>If @Table is missing, Hibernate uses the class name as the table name.</li></ul><pre>@Entity<br>@Table(name = &quot;employee_master&quot;, schema = &quot;hr&quot;)<br>public class Employee { ... }</pre><h3>@Id</h3><ul><li><strong>Purpose:</strong> Marks a field as the <strong>Primary Key</strong>.</li><li>Every entity <strong>must</strong> have exactly one id.</li></ul><pre>@Id<br>private Long empId;</pre><h3>@GeneratedValue</h3><ul><li>Auto-generate primary key values.</li><li><strong>Strategies:</strong></li></ul><ol><li>AUTO → Hibernate chooses.</li><li>IDENTITY → DB auto-increment.</li><li>SEQUENCE → Uses database sequence.</li><li>TABLE → Uses table for id generation.</li></ol><pre>@Id<br>@GeneratedValue(strategy = GenerationType.IDENTITY)<br>private Long id;</pre><p><strong>Note: </strong>In Oracle, prefer SEQUENCE. In MySQL, IDENTITY is common.</p><h3>@Column</h3><ul><li>Maps a field to a DB column.</li><li><strong>Options:</strong> name, nullable, length, unique.</li><li>If not used, Hibernate maps field name to column name.</li></ul><pre>@Column(name = &quot;emp_name&quot;, length = 100, nullable = false)<br>private String name;</pre><h3>@Transient</h3><ul><li>Ignores a field (not persisted).</li><li>Used for calculated fields (not stored in DB).</li></ul><pre>@Transient<br>private int tempValue;</pre><h3>@Lob</h3><ul><li>Stores large objects (CLOB / BLOB).</li><li>Good for images, files, long text.</li></ul><pre>@Lob<br>private byte[] profilePicture;</pre><h3>@Temporal &amp; @CreationTimestamp, @UpdateTimestamp</h3><ul><li>Handling date/time fields.</li><li>@CreationTimestamp and @UpdateTimestamp are Hibernate-specific.</li></ul><pre>@Temporal(TemporalType.TIMESTAMP)<br>private Date createdAt;<br><br>@CreationTimestamp<br>private LocalDateTime createdOn;<br><br>@UpdateTimestamp<br>private LocalDateTime updatedOn;</pre><h3>@Enumerated</h3><ul><li>Store enums as ORDINAL (number) or STRING.</li><li>Always prefer STRING to avoid issues when enum order changes.</li></ul><pre>public enum Status { ACTIVE, INACTIVE }<br><br>@Enumerated(EnumType.STRING)<br>private Status status;</pre><h3>Relationship Annotations</h3><p>I. OneToOne</p><pre>@OneToOne<br>@JoinColumn(name = &quot;profile_id&quot;)<br>private Profile profile;</pre><p>II. OneToMany</p><pre>@OneToMany(mappedBy = &quot;employee&quot;)<br>private List&lt;Address&gt; addresses;</pre><p>III. ManyToOne</p><pre>@ManyToOne<br>@JoinColumn(name = &quot;dept_id&quot;)<br>private Department department;</pre><p>IV. MayToMany</p><pre>@ManyToMany<br>@JoinTable(<br>  name = &quot;student_course&quot;,<br>  joinColumns = @JoinColumn(name = &quot;student_id&quot;),<br>  inverseJoinColumns = @JoinColumn(name = &quot;course_id&quot;)<br>)<br>private List&lt;Course&gt; courses;</pre><h3>@Embedded &amp; @Embeddable</h3><ul><li>Use reusable value objects inside entities.</li><li>Helps in normalizing code (value objects).</li></ul><pre>@Embeddable<br>public class Address {<br>    private String city;<br>    private String state;<br>}<br><br>@Entity<br>public class Employee {<br>    @Embedded<br>    private Address address;<br>}</pre><h3>@NamedQuery &amp; @NamedNativeQuery</h3><ul><li>Predefined JPQL/SQL queries.</li><li>Better than inline queries when reused often.</li></ul><pre>@NamedQuery(<br>  name = &quot;Employee.findByName&quot;,<br>  query = &quot;SELECT e FROM Employee e WHERE e.name = :name&quot;<br>)<br>@Entity<br>public class Employee { ... }</pre><h3>@SQLDelete, @Where (Hibernate-specific)</h3><ul><li>Hibernate-specific but used in real projects for soft deletes.</li></ul><pre>@SQLDelete(sql = &quot;UPDATE employee SET deleted = true WHERE id = ?&quot;)<br>@Where(clause = &quot;deleted = false&quot;)<br>public class Employee { ... }</pre><h3>Interview-Focused Quick Summary</h3><ul><li>@Entity, @Id, @GeneratedValue → Basic essentials.</li><li>@Column, @Table → Custom mappings.</li><li>@OneToOne, @OneToMany, @ManyToMany → Relationships (most asked).</li><li>@Enumerated, @Lob, @Transient → Special cases.</li><li>@CreationTimestamp, @UpdateTimestamp → Auto timestamps.</li><li>CascadeType &amp; FetchType → Always mentioned in interviews.</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5cbe1fe4e93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dependency Injection Annotations in Spring Boot]]></title>
            <link>https://medium.com/@roshanfarakate/dependency-injection-annotations-in-spring-boot-0be3034be8ff?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0be3034be8ff</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[java-annotations]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 12:42:57 GMT</pubDate>
            <atom:updated>2025-08-22T12:42:57.110Z</atom:updated>
            <content:encoded><![CDATA[<p><em>D</em>ependency Injection (DI) is at the heart of the Spring Framework. It allows developers to build loosely coupled applications by delegating the responsibility of creating and managing objects (dependencies) to the Spring IoC (Inversion of Control) container. Instead of classes creating their own objects, Spring injects them when required.</p><h3>@Autowired</h3><ul><li>Tells Spring to automatically inject a dependency by <strong>type</strong>.</li><li><strong>Where used</strong>: On fields, constructors, or setter methods.</li></ul><pre>@Service<br>public class OrderService {<br><br>    @Autowired<br>    private PaymentService paymentService; // Injected automatically<br>}</pre><p>Constructor Injection (Best Practice):</p><pre>@Service<br>public class OrderService {<br><br>    private final PaymentService paymentService;<br><br>    @Autowired<br>    public OrderService(PaymentService paymentService) {<br>        this.paymentService = paymentService;<br>    }<br>}</pre><p><strong>Notes:</strong></p><ul><li>If there’s only <strong>one constructor</strong>, @Autowired is optional (Spring auto-wires it).</li><li>If multiple beans of the same type exist, Spring throws an exception unless resolved with @Qualifier or @Primary.</li><li>Constructor injection is preferred over field injection because it ensures immutability and makes classes easier to test.</li></ul><h3>@Qualifier</h3><ul><li>Resolves conflicts when multiple beans of the same type exist by specifying the <strong>bean name</strong>.</li><li><strong>Used with</strong>: @Autowired.</li></ul><pre>@Service(&quot;creditCardPayment&quot;)<br>public class CreditCardPaymentService implements PaymentService {}<br><br>@Service(&quot;upiPayment&quot;)<br>public class UpiPaymentService implements PaymentService {}<br><br>@Service<br>public class OrderService {<br>    <br>    @Autowired<br>    @Qualifier(&quot;upiPayment&quot;)<br>    private PaymentService paymentService; // Chooses UPI Payment<br>}</pre><p><strong>Notes:</strong></p><ul><li>Bean name defaults to the <strong>class name with lowercase first letter</strong>, unless explicitly provided (@Service(&quot;beanName&quot;)).</li><li>Useful when you have multiple implementations of an interface.</li></ul><h3>@Value</h3><ul><li><strong>Purpose</strong>: Injects values from <strong>application.properties</strong>, <strong>application.yml</strong>, or <strong>environment variables</strong>.</li><li><strong>Usage</strong>: Great for configuration values.</li></ul><pre># application.properties<br>app.name=Payment Application<br>app.timeout=5000</pre><pre>@Service<br>public class ConfigService {<br><br>    @Value(&quot;${app.name}&quot;)<br>    private String appName;<br><br>    @Value(&quot;${app.timeout}&quot;)<br>    private int timeout;<br><br>    public void printConfig() {<br>        System.out.println(appName + &quot; runs with timeout: &quot; + timeout);<br>    }<br>}</pre><p>Advanced Example with Default Value:</p><pre>@Value(&quot;${app.version:1.0}&quot;)<br>private String appVersion; // Defaults to 1.0 if not found</pre><p><strong>Note:</strong> @Value is perfect for <strong>simple properties</strong>, but for structured configs, use @ConfigurationProperties.</p><h3>@Primary</h3><ul><li>Marks a bean as the <strong>default</strong> choice when multiple candidates exist.</li><li><strong>Alternative to</strong>: Using @Qualifier everywhere.</li></ul><pre>@Service<br>@Primary<br>public class CreditCardPaymentService implements PaymentService {}<br><br>@Service<br>public class UpiPaymentService implements PaymentService {}<br><br>@Service<br>public class OrderService {<br><br>    @Autowired<br>    private PaymentService paymentService; // CreditCardPayment is injected by default<br>}</pre><p><strong>Notes:</strong></p><ul><li>Use @Primary when one bean should be the default across the application.</li><li>If @Qualifier is present, it overrides @Primary.</li><li>@Primary sets a <strong>default</strong>. @Qualifier makes an <strong>explicit choice</strong>.</li></ul><h3>Summary</h3><ul><li><strong>@Autowired</strong> → Auto-injects bean <strong>by type</strong>.</li><li><strong>@Qualifier</strong> → Resolve ambiguity by choosing bean <strong>by name</strong>.</li><li><strong>@Value</strong> → Inject values from <strong>properties/environment</strong>.</li><li><strong>@Primary</strong> → Set a <strong>default bean</strong> when multiple exist.</li></ul><h3>Best Practices</h3><ul><li>Prefer <strong>constructor injection</strong> (@Autowired optional if one constructor).</li><li>Use @Qualifier when you need fine-grained control.</li><li>Use @Primary when one bean should be the default.</li><li>Use @Value for simple values; prefer @ConfigurationProperties for grouped configs.</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0be3034be8ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Web & REST Annotations]]></title>
            <link>https://medium.com/@roshanfarakate/spring-web-rest-annotations-e3fd2178db0a?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3fd2178db0a</guid>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[java-annotations]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 11:45:09 GMT</pubDate>
            <atom:updated>2025-08-22T11:45:09.275Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Boot has made web application and REST API development simple and powerful. At the core of this lies the <strong>annotations</strong> provided by the Spring Framework, which abstract away boilerplate code and let developers focus on business logic.</p><p>In this article we will be focusing on the following annotations: <br><strong>@RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping, @PathVariable, @RequestParam, @RequestBody, @ResponseBody, @CrossOrigin,</strong></p><h3><strong>@RequestMapping</strong></h3><ul><li>Maps HTTP requests to handler methods (can handle GET, POST, PUT, DELETE, etc.).</li><li>Can be applied at <strong>class</strong> and <strong>method</strong> levels.</li></ul><pre>@RestController<br>@RequestMapping(&quot;/api/products&quot;)<br>public class ProductController {<br>    <br>    @RequestMapping(value = &quot;/all&quot;, method = RequestMethod.GET)<br>    public List&lt;String&gt; getAllProducts() {<br>        return List.of(&quot;Laptop&quot;, &quot;Phone&quot;);<br>    }<br>}</pre><p>@RequestMapping is generic and can map multiple HTTP methods with one annotation.</p><h3>@GetMapping</h3><ul><li>Specialized version of @RequestMapping for <strong>HTTP GET</strong> requests.</li></ul><pre>@GetMapping(&quot;/users/{id}&quot;)<br>public String getUser(@PathVariable int id) {<br>    return &quot;User &quot; + id;<br>}</pre><ul><li>GET is <strong>safe &amp; idempotent</strong> (doesn’t change server state).</li><li>Use for <strong>retrieving data</strong> only.</li></ul><h3>@PostMapping</h3><ul><li>Handles <strong>HTTP POST</strong> requests. Used to create resources.</li></ul><pre>@PostMapping(&quot;/users&quot;)<br>public String createUser(@RequestBody String user) {<br>    return &quot;Created: &quot; + user;<br>}</pre><ul><li>POST is <strong>not idempotent</strong> (multiple requests = multiple creations).</li></ul><h3>@PutMapping</h3><ul><li><strong>Definition</strong>: Handles <strong>HTTP PUT</strong> requests, usually for full updates.</li></ul><pre>@PutMapping(&quot;/users/{id}&quot;)<br>public String updateUser(@PathVariable int id, @RequestBody String user) {<br>    return &quot;Updated &quot; + id + &quot; with &quot; + user;<br>}</pre><ul><li>PUT is <strong>idempotent</strong> (same request = same result).</li><li>Replaces the <strong>entire resource</strong>, not partial updates.</li></ul><h3>@DeleteMapping</h3><ul><li><strong>Definition</strong>: Handles <strong>HTTP DELETE</strong> requests.</li></ul><pre>@DeleteMapping(&quot;/users/{id}&quot;)<br>public String deleteUser(@PathVariable int id) {<br>    return &quot;Deleted User &quot; + id;<br>}</pre><ul><li>DELETE is also <strong>idempotent</strong>.</li><li>Multiple DELETE calls for same ID → same outcome.</li></ul><h3>@PatchMapping</h3><ul><li><strong>Definition</strong>: Handles <strong>HTTP PATCH</strong> requests. Used for <strong>partial updates</strong>.</li></ul><pre>@PatchMapping(&quot;/users/{id}&quot;)<br>public String patchUser(@PathVariable int id, @RequestBody String field) {<br>    return &quot;Patched User &quot; + id + &quot; with &quot; + field;<br>}</pre><ul><li>PUT = replace full object, PATCH = update only specific fields.</li></ul><h3>@PathVariable</h3><ul><li>Extracts values from the <strong>URI path</strong>.</li></ul><pre>@GetMapping(&quot;/orders/{orderId}&quot;)<br>public String getOrder(@PathVariable(&quot;orderId&quot;) int id) {<br>    return &quot;Order &quot; + id;<br>}</pre><ul><li>PathVariable = part of URL path, RequestParam = query params.</li></ul><h3>@RequestParam</h3><ul><li>Extracts query string parameters (?key=value).</li></ul><pre>@GetMapping(&quot;/search&quot;)<br>public String search(@RequestParam String keyword,<br>                     @RequestParam(defaultValue = &quot;10&quot;) int limit) {<br>    return &quot;Searching &quot; + keyword + &quot; with limit &quot; + limit;<br>}</pre><ul><li>required=true by default. Missing parameter → exception.</li><li>Use for <strong>filters, pagination, sorting</strong>, not resource identity.</li></ul><h3>@RequestBody</h3><ul><li><strong>Definition</strong>: Binds request body (JSON/XML) to a Java object.</li></ul><pre>@PostMapping(&quot;/users&quot;)<br>public String addUser(@RequestBody User user) {<br>    return &quot;User: &quot; + user.getName();<br>}</pre><ul><li>Works with <strong>HttpMessageConverters</strong> (Jackson for JSON).</li><li>RequestBody = body (JSON/XML), ModelAttribute = query/form data.</li></ul><h3>@ResponseBody</h3><ul><li>Tells Spring to return the object directly as HTTP response (JSON/XML), instead of a view.</li></ul><pre>@Controller<br>public class DemoController {<br>    @GetMapping(&quot;/hello&quot;)<br>    @ResponseBody<br>    public String sayHello() {<br>        return &quot;Hello, World!&quot;;<br>    }<br>}</pre><p><strong>Note</strong>: @RestController already includes this → no need to write separately.</p><h3>@CrossOrigin</h3><ul><li><strong>Definition</strong>: Enables <strong>CORS</strong> (Cross-Origin Resource Sharing).</li></ul><pre>@CrossOrigin(origins = &quot;http://localhost:3000&quot;)<br>@RestController<br>public class ApiController {<br>    @GetMapping(&quot;/data&quot;)<br>    public String getData() {<br>        return &quot;Backend Data&quot;;<br>    }<br>}</pre><ul><li>What is CORS? → Security mechanism by browsers to restrict cross-origin requests.</li><li>How to enable globally? → Implement WebMvcConfigurer and override addCorsMappings().</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3fd2178db0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stereotype Annotations in Spring Boot]]></title>
            <link>https://medium.com/@roshanfarakate/stereotype-annotations-in-spring-boot-2f5d6405a6bc?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f5d6405a6bc</guid>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java-annotations]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 09:42:17 GMT</pubDate>
            <atom:updated>2025-08-18T11:10:49.600Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with <strong>Spring Boot</strong>, one of the first concepts you’ll encounter is how Spring <strong>manages beans</strong>. Beans are simply Java objects that Spring creates, configures, and manages for you.</p><p>But how does Spring know which classes to turn into beans?<br> That’s where <strong>Stereotype Annotations</strong> come into play.</p><h4><strong>What are Stereotype Annotations?</strong></h4><p>In Spring, <strong>Stereotype Annotations</strong> are special annotations used to <strong>mark classes as beans</strong> that should be automatically detected and registered in the Spring ApplicationContext during <strong>component scanning</strong>.</p><p>They are called <strong>“stereotypes”</strong> because they indicate the <strong>role</strong> a particular class plays in the application (Controller, Service, Repository, etc.).</p><p>In simple terms:<br> Instead of writing XML or Java config to declare beans, you just mark them with annotations.</p><h3>The Core Stereotype Annotations</h3><h3><strong>@Component</strong></h3><ul><li>The most <strong>generic stereotype annotation</strong>.</li><li>Marks a class as a Spring bean, without assigning it a specific layer role.</li></ul><pre>@Component<br>public class EmailValidator {<br>    public boolean isValid(String email) {<br>        return email != null &amp;&amp; email.contains(&quot;@&quot;);<br>    }<br>}</pre><p><strong>When to use</strong>: For utility classes, helper classes, or generic beans that don’t belong to a specific layer.</p><p>@Component is the parent annotation; all others (@Service, @Repository, @Controller) are just <strong>specializations</strong> of it.</p><h3><strong>@Service</strong></h3><ul><li>A specialization of @Component annotation.</li><li>Indicates that the class contains <strong>business logic</strong> (service layer).</li></ul><pre>@Service<br>public class PaymentService {<br>    public void processPayment(String orderId) {<br>        // business logic to process payment<br>    }<br>}</pre><p><strong>When to use</strong>: For classes that contain <strong>business operations</strong> like order processing, calculations, rules, etc. Functionally identical to @Component, but the annotation helps with <strong>readability and role clarity</strong></p><h3><strong>@Repository</strong></h3><ul><li>Specialization of @Component used for <strong>DAO (Data Access Layer)</strong> classes.</li><li>Provides <strong>automatic exception translation</strong> → converts database-related exceptions (like Hibernate/JPA exceptions) into <strong>Spring’s DataAccessException</strong> hierarchy.</li></ul><pre>@Repository<br>public interface UserRepository extends JpaRepository&lt;User, Long&gt; {<br>    Optional&lt;User&gt; findByEmail(String email);<br>}</pre><p><strong>When to use</strong>: For database operations — JPA Repositories, DAOs, JDBC templates. The Spring container applies a <strong>PersistenceExceptionTranslationPostProcessor</strong>, which wraps exceptions into Spring-friendly exceptions.</p><h3><strong>@Controller</strong></h3><ul><li>A specialization of @Component used in the <strong>Presentation Layer</strong> (Spring MVC).</li><li>Marks a class as a <strong>Spring MVC Controller</strong> that handles <strong>HTTP requests</strong>.</li><li>Works with view templates (e.g. Thymeleaf, JSP).</li></ul><pre>@Controller<br>public class HomeController {<br>    @GetMapping(&quot;/&quot;)<br>    public String homePage() {<br>        return &quot;index&quot;; // resolves to index.html or index.jsp<br>    }<br>}</pre><p><strong>When to use</strong>: For classes that return <strong>views (UI pages)</strong>, not JSON.</p><h3><strong>@RestController</strong></h3><ul><li>A specialization of @Controller introduced in Spring 4.</li><li>Combines @Controller and @ResponseBody.</li><li>@ResponseBody is applied to every method automatically behind the scene.</li><li>All methods return <strong>JSON/XML</strong> instead of views.</li></ul><pre>@RestController<br>@RequestMapping(&quot;/api/users&quot;)<br>public class UserController {<br>    <br>    @GetMapping(&quot;/{id}&quot;) <br>    public User getUser(@PathVariable Long id) {<br>        return new User(id, &quot;John&quot;, &quot;Doe&quot;);<br>    }<br>}<br><br>//Read about @RequestMapping @GetMapping and @PathVariable in upcoming stories</pre><p><strong>When to use</strong>: For <strong>RESTful Web Services</strong> where data is returned as JSON/XML.</p><h3>How Stereotype Annotations Work with @ComponentScan</h3><p>All stereotype annotations are detected because of <strong>@ComponentScan</strong>, which is included in @SpringBootApplication.</p><p>Automatically scans the package com.example.myapp and its subpackages for @Component, @Service, @Repository, @Controller, and @RestController.</p><p>If you need to scan other packages:</p><pre>@SpringBootApplication<br>@ComponentScan(basePackages = {&quot;com.example.services&quot;, &quot;com.example.controllers&quot;})<br>public class MyApplication { }</pre><h3>Interview FAQs</h3><ol><li>Are @Service, @Repository, @Controller different from @Component?</li></ol><ul><li><em>Technically they are all the same in bean registration, but they provide </em><strong><em>semantic meaning</em></strong><em> and extra functionality (</em><em>@Repository adds exception translation).</em></li></ul><p>2. What happens if we annotate a DAO class with @Component instead of @Repository?</p><ul><li><em>It will still work, but you’ll </em><strong><em>lose exception translation</em></strong>.</li></ul><p>3. Can I use @RestController in place of @Controller?</p><ul><li><em>Only if you are returning </em><strong><em>JSON/XML</em></strong><em>. For view-based applications, use </em><em>@Controller.</em></li></ul><p>4. How does Spring find these beans?</p><ul><li><em>Via </em><strong><em>component scanning</em></strong><em>, triggered by </em><em>@SpringBootApplication (or explicitly with </em><em>@ComponentScan).</em></li></ul><p>5. Is there any functional difference between @Component and @Service?</p><ul><li><em>No technical difference, but </em><em>@Service improves semantic clarity and is used for service-layer beans.</em></li></ul><p>6. What is the difference between @Repository and @Component?</p><ul><li><em>Both register beans, but </em><em>@Repository also </em><strong><em>enables exception translation</em></strong><em>, making it better for persistence layer classes.</em></li></ul><p>7. Difference between @Controller and @RestController?</p><ul><li><em>@Controller is used for </em><strong><em>views</em></strong><em>, </em><em>@RestController is for </em><strong><em>REST APIs</em></strong><em> (returns JSON/XML).</em></li></ul><h3><strong>Summary points:</strong></h3><ul><li>@Component → Generic bean.</li><li>@Service → Business logic.</li><li>@Repository → Persistence layer with exception translation.</li><li>@Controller → Web MVC controller (views).</li><li>@RestController → REST APIs (JSON/XML).</li></ul><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f5d6405a6bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Spring Boot Annotations (@SpringBootAnnotation, @Configuration, @ComponentScan…]]></title>
            <link>https://medium.com/@roshanfarakate/core-spring-boot-annotations-springbootannotation-configuration-componentscan-9781bca23168?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9781bca23168</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[annotations]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 08:54:28 GMT</pubDate>
            <atom:updated>2025-08-18T11:09:12.713Z</atom:updated>
            <content:encoded><![CDATA[<h3>Core Spring Boot Annotations (@SpringBootAnnotation, @Configuration, @ComponentScan, @EnableAutoConfiguration)</h3><p>For interviews, knowing the <strong>core annotations in Spring Boot</strong> is very important because they are the backbone of how Spring Boot applications are built.</p><h3><strong>@SpringBootApplication</strong></h3><p>A convenience annotation introduced in Spring Boot. It enables <strong>auto-configuration, component scanning, and bean registration</strong>.</p><pre>@SpringBootApplication<br>public class MyApplication {<br>    public static void main(String[] args) {<br>        SpringApplication.run(MyApplication.class, args);<br>    }<br>}</pre><ul><li>It is a <strong>meta-annotation</strong> that combines:</li></ul><p><strong>@Configuration</strong> → Treats the class as a source of bean definitions.</p><p><strong>@EnableAutoConfiguration</strong> → Enables Spring Boot to automatically configure beans based on classpath and dependencies.</p><p><strong>@ComponentScan</strong> → Scans the package where the class resides (and subpackages) for @Component, @Service, @Repository, @Controller, etc.</p><h3><strong>@Configuration</strong></h3><ul><li>Marks a class as a configuration class that provides <strong>bean definitions</strong> for the Spring container.</li><li>Equivalent to <strong>XML-based configuration</strong>, but in Java.</li></ul><pre>@Configuration<br>public class AppConfig {<br><br>    @Bean<br>    public RestTemplate restTemplate() {<br>        return new RestTemplate();<br>    }<br>}</pre><ul><li>Used to define beans with @ bean methods.</li><li>Ensures <strong>singleton behavior</strong> by default → Spring creates only one instance of the bean and manages it.</li><li>It’s <strong>processed by Spring’s IoC container</strong> to generate and manage bean definitions.</li></ul><h3>@ComponentScan</h3><p>Tells Spring <strong>where to look for beans</strong> i.e. which packages to scan for classes annotated with @Component, @Service, @Repository, @Controller,etc.</p><p>By default, it scans the <strong>package of the class where </strong><strong>@SpringBootApplication is placed</strong>.</p><pre>@SpringBootApplication<br>@ComponentScan(basePackages = {&quot;com.example.service&quot;, &quot;com.example.controller&quot;})<br>public class MyApplication { <br><br>}</pre><ul><li>Avoids manual bean definitions by automatically detecting them.</li><li>You can <strong>customize packages</strong> using basePackages attribute.</li></ul><h3>@EnableAutoConfiguration</h3><p>Tells Spring Boot to automatically configure beans based on the <strong>classpath dependencies</strong>.</p><p>Example:</p><ul><li>If spring-boot-starter-web is present → Configures <strong>DispatcherServlet</strong>, Jackson, and embedded Tomcat.</li><li>If spring-boot-starter-data-jpa is present → Configures <strong>EntityManagerFactory</strong>, Hibernate, and DataSource.</li></ul><pre>@EnableAutoConfiguration<br>public class MyAppConfig { <br><br>}</pre><h3>How it works:</h3><ul><li>Uses <strong>Spring Factories (</strong><strong>spring.factories)</strong> mechanism.</li><li>Loads configuration classes from META-INF/spring.factories provided by Spring Boot and third-party libraries.</li></ul><p>Example entry inside spring.factories:</p><pre>org.springframework.boot.autoconfigure.EnableAutoConfiguration=\<br>org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\<br>org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration</pre><p>To disable a specific auto-configuration:</p><pre>@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})</pre><h3>Interview Insights:</h3><ol><li><em>Can we replace </em><em>@SpringBootApplication?</em> -&gt; Yes, by using its three annotations separately.</li><li><em>Difference between </em><em>@Component and </em><em>@Configuration? -&gt; </em>@Component just registers a bean, while @Configuration is for <strong>Java-based configuration + bean definitions. </strong>Beans inside @Configuration are proxied by <strong>CGLIB</strong> to ensure singleton scope.</li><li><em>What happens if I put my Spring Boot main class in a subpackage? -&gt; </em>Beans in parent or sibling packages won’t be scanned unless you explicitly configure @ComponentScan.</li><li><em>What is the difference between </em><em>@EnableAutoConfiguration and </em><em>@Configuration? -&gt; </em>@Configuration → manual bean definition.<br> @EnableAutoConfiguration → automatic bean registration based on classpath.</li></ol><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9781bca23168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth2 Best Practices and Security Considerations]]></title>
            <link>https://medium.com/@roshanfarakate/oauth2-best-practices-and-security-considerations-edea3d05559f?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/edea3d05559f</guid>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 16:35:47 GMT</pubDate>
            <atom:updated>2025-08-18T11:13:08.676Z</atom:updated>
            <content:encoded><![CDATA[<p>Read previous story to understand implementation of OAuth2 in spring Boot : <a href="https://medium.com/@roshanfarakate/implement-oauth2-in-spring-boot-project-0d37cdd8f9b8">Link</a></p><h3>1. Secure Token Storage</h3><ul><li>Use HTTP-only cookies for web applications</li><li>Implement proper token refresh mechanisms</li><li>Store sensitive tokens securely (encrypted)</li></ul><h3><strong>2. Scope Management</strong></h3><pre>@Configuration<br>public class OAuth2ScopeConfig {<br>    <br>    @Bean<br>    public OAuth2AuthorizedClientService authorizedClientService(<br>            ClientRegistrationRepository clientRegistrationRepository) {<br>        return new InMemoryOAuth2AuthorizedClientService(clientRegistrationRepository);<br>    }<br>    <br>    @Bean<br>    public OAuth2AuthorizedClientManager authorizedClientManager(<br>            ClientRegistrationRepository clientRegistrationRepository,<br>            OAuth2AuthorizedClientService authorizedClientService) {<br>        <br>        OAuth2AuthorizedClientProvider authorizedClientProvider =<br>            OAuth2AuthorizedClientProviderBuilder.builder()<br>                .authorizationCode()<br>                .refreshToken()<br>                .clientCredentials()<br>                .build();<br>        <br>        DefaultOAuth2AuthorizedClientManager authorizedClientManager =<br>            new DefaultOAuth2AuthorizedClientManager(<br>                clientRegistrationRepository, authorizedClientService);<br>        authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);<br>        <br>        return authorizedClientManager;<br>    }<br>}</pre><h3><strong>3. Error Handling</strong></h3><pre>@ControllerAdvice<br>public class OAuth2ExceptionHandler {<br><br>    @ExceptionHandler(OAuth2AuthenticationException.class)<br>    public ResponseEntity&lt;ErrorResponse&gt; handleOAuth2Exception(OAuth2AuthenticationException ex) {<br>        ErrorResponse error = ErrorResponse.builder()<br>            .message(&quot;Authentication failed&quot;)<br>            .details(ex.getMessage())<br>            .timestamp(LocalDateTime.now())<br>            .build();<br>        <br>        return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(error);<br>    }<br>}</pre><h3>Common Pitfalls and Troubleshooting</h3><h3>1. CORS Configuration</h3><pre>@Configuration<br>public class CorsConfig implements WebMvcConfigurer {<br>    <br>    @Override<br>    public void addCorsMappings(CorsRegistry registry) {<br>        registry.addMapping(&quot;/api/**&quot;)<br>            .allowedOrigins(&quot;http://localhost:3000&quot;)<br>            .allowedMethods(&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot;, &quot;OPTIONS&quot;)<br>            .allowedHeaders(&quot;*&quot;)<br>            .allowCredentials(true);<br>    }<br>}</pre><h3>2. Token Validation Issues</h3><ul><li>Ensure clock synchronization between services</li><li>Verify JWT signature algorithms match</li><li>Check token expiration times</li></ul><h3>3. Redirect URI Mismatches</h3><ul><li>Ensure redirect URIs in configuration match provider settings</li><li>Use HTTPS in production environments</li><li>Handle multiple redirect URIs properly</li></ul><h3>Monitoring and Logging</h3><h3>Custom Metrics</h3><pre>@Component<br>public class OAuth2Metrics {<br>    <br>    private final Counter authenticationAttempts;<br>    private final Counter authenticationSuccesses;<br>    private final Counter authenticationFailures;<br>    <br>    public OAuth2Metrics(MeterRegistry meterRegistry) {<br>        this.authenticationAttempts = Counter.builder(&quot;oauth2.authentication.attempts&quot;)<br>            .description(&quot;Total OAuth2 authentication attempts&quot;)<br>            .register(meterRegistry);<br>        this.authenticationSuccesses = Counter.builder(&quot;oauth2.authentication.success&quot;)<br>            .description(&quot;Successful OAuth2 authentications&quot;)<br>            .register(meterRegistry);<br>        this.authenticationFailures = Counter.builder(&quot;oauth2.authentication.failure&quot;)<br>            .description(&quot;Failed OAuth2 authentications&quot;)<br>            .register(meterRegistry);<br>    }<br>    <br>    public void recordAuthenticationAttempt() {<br>        authenticationAttempts.increment();<br>    }<br>    <br>    public void recordAuthenticationSuccess() {<br>        authenticationSuccesses.increment();<br>    }<br>    <br>    public void recordAuthenticationFailure() {<br>        authenticationFailures.increment();<br>    }<br>}</pre><h3>Conclusion</h3><p>OAuth2 integration with Spring Boot provides a robust foundation for modern application security. By following the patterns and practices outlined in this guide, you can implement secure, scalable authentication systems that protect user data while providing excellent user experience.</p><p>Remember to always:</p><ul><li>Keep dependencies updated</li><li>Follow security best practices</li><li>Test thoroughly in different environments</li><li>Monitor authentication metrics</li><li>Handle errors gracefully</li></ul><p>The combination of Spring Boot’s auto-configuration and OAuth2’s flexibility makes it an excellent choice for both simple and complex authentication scenarios. Start with basic implementations and gradually add advanced features as your application requirements grow.</p><h3>More resources:</h3><ol><li><a href="https://datatracker.ietf.org/doc/html/rfc6749">OAuth2 RFC 6749</a></li><li><a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT RFC 7519</a></li><li><a href="https://spring.io/guides/gs/securing-web">Spring Boot Security Documentation</a></li></ol><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edea3d05559f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement OAuth2 in Spring Boot Project]]></title>
            <link>https://medium.com/@roshanfarakate/implement-oauth2-in-spring-boot-project-0d37cdd8f9b8?source=rss-518c63b10c4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d37cdd8f9b8</guid>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Roshan Farakate]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 16:29:00 GMT</pubDate>
            <atom:updated>2025-08-18T11:16:54.651Z</atom:updated>
            <content:encoded><![CDATA[<p>Read previous story before to understand basics: <a href="https://medium.com/@roshanfarakate/mastering-oauth2-in-spring-boot-563a0f67558d">Link</a></p><p>Implementing OAuth2 in spring boot:</p><h4><strong>Setting Up OAuth2 in Spring Boot</strong></h4><p>Dependencies</p><p>First, add the necessary dependencies to your pom.xml:</p><pre>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-oauth2-client&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-oauth2-resource-server&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><h3>Basic Configuration</h3><p>Configure OAuth2 properties in application.yml:</p><pre>spring:<br>  security:<br>    oauth2:<br>      client:<br>        registration:<br>          google:<br>            client-id: ${GOOGLE_CLIENT_ID}<br>            client-secret: ${GOOGLE_CLIENT_SECRET}<br>            scope:<br>              - openid<br>              - profile<br>              - email<br>          github:<br>            client-id: ${GITHUB_CLIENT_ID}<br>            client-secret: ${GITHUB_CLIENT_SECRET}<br>            scope:<br>              - user:email<br>              - read:user<br>        provider:<br>          google:<br>            authorization-uri: https://accounts.google.com/o/oauth2/auth<br>            token-uri: https://oauth2.googleapis.com/token<br>            user-info-uri: https://www.googleapis.com/oauth2/v2/userinfo<br>            user-name-attribute: email</pre><h4>Implementing OAuth2 Client</h4><h4>Security Configuration Class</h4><pre>@Configuration<br>@EnableWebSecurity<br>public class SecurityConfig {<br><br>    @Bean<br>    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {<br>        http<br>            .authorizeHttpRequests(authz -&gt; authz<br>                .requestMatchers(&quot;/&quot;, &quot;/login&quot;, &quot;/error&quot;).permitAll()<br>                .anyRequest().authenticated()<br>            )<br>            .oauth2Login(oauth2 -&gt; oauth2<br>                .loginPage(&quot;/login&quot;)<br>                .defaultSuccessUrl(&quot;/dashboard&quot;, true)<br>                .failureUrl(&quot;/login?error&quot;)<br>                .userInfoEndpoint(userInfo -&gt; userInfo<br>                    .userService(customOAuth2UserService())<br>                )<br>            )<br>            .logout(logout -&gt; logout<br>                .logoutSuccessUrl(&quot;/&quot;)<br>                .invalidateHttpSession(true)<br>                .clearAuthentication(true)<br>            );<br>        <br>        return http.build();<br>    }<br><br>    @Bean<br>    public OAuth2UserService&lt;OAuth2UserRequest, OAuth2User&gt; customOAuth2UserService() {<br>        return new CustomOAuth2UserService();<br>    }<br>}</pre><p><strong>Custom OAuth2 User Implementation</strong></p><pre>public class CustomOAuth2User implements OAuth2User {<br>    private OAuth2User oauth2User;<br>    private String registrationId;<br>    private String userNameAttributeName;<br>    <br>    public CustomOAuth2User(OAuth2User oauth2User, String registrationId, String userNameAttributeName) {<br>        this.oauth2User = oauth2User;<br>        this.registrationId = registrationId;<br>        this.userNameAttributeName = userNameAttributeName;<br>    }<br>    <br>    @Override<br>    public Map&lt;String, Object&gt; getAttributes() {<br>        return oauth2User.getAttributes();<br>    }<br>    <br>    @Override<br>    public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() {<br>        return oauth2User.getAuthorities();<br>    }<br>    <br>    @Override<br>    public String getName() {<br>        return oauth2User.getAttribute(userNameAttributeName);<br>    }<br>    <br>    public String getEmail() {<br>        return oauth2User.getAttribute(&quot;email&quot;);<br>    }<br>    <br>    public String getRegistrationId() {<br>        return registrationId;<br>    }<br>}</pre><h4>Implementing OAuth2 Resource Server</h4><h4>JWT Configuration</h4><pre>@Configuration<br>@EnableWebSecurity<br>@EnableMethodSecurity<br>public class ResourceServerConfig {<br><br>    @Bean<br>    public SecurityFilterChain resourceServerFilterChain(HttpSecurity http) throws Exception {<br>        http<br>            .authorizeHttpRequests(authz -&gt; authz<br>                .requestMatchers(&quot;/api/public/**&quot;).permitAll()<br>                .requestMatchers(&quot;/api/admin/**&quot;).hasRole(&quot;ADMIN&quot;)<br>                .anyRequest().authenticated()<br>            )<br>            .oauth2ResourceServer(oauth2 -&gt; oauth2<br>                .jwt(jwt -&gt; jwt<br>                    .decoder(jwtDecoder())<br>                    .jwtAuthenticationConverter(jwtAuthenticationConverter())<br>                )<br>            )<br>            .sessionManagement(session -&gt; session<br>                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)<br>            );<br>        <br>        return http.build();<br>    }<br><br>    @Bean<br>    public JwtDecoder jwtDecoder() {<br>        return NimbusJwtDecoder.withJwkSetUri(&quot;https://your-auth-server/.well-known/jwks.json&quot;).build();<br>    }<br><br>    @Bean<br>    public JwtAuthenticationConverter jwtAuthenticationConverter() {<br>        JwtGrantedAuthoritiesConverter authoritiesConverter = new JwtGrantedAuthoritiesConverter();<br>        authoritiesConverter.setAuthorityPrefix(&quot;ROLE_&quot;);<br>        authoritiesConverter.setAuthoritiesClaimName(&quot;roles&quot;);<br><br>        JwtAuthenticationConverter converter = new JwtAuthenticationConverter();<br>        converter.setJwtGrantedAuthoritiesConverter(authoritiesConverter);<br>        return converter;<br>    }<br>}</pre><h4>Creating Protected Endpoints</h4><h4>REST Controller with Security</h4><pre>@RestController<br>@RequestMapping(&quot;/api&quot;)<br>public class ApiController {<br><br>    @GetMapping(&quot;/user/profile&quot;)<br>    @PreAuthorize(&quot;hasRole(&#39;USER&#39;)&quot;)<br>    public ResponseEntity&lt;UserProfile&gt; getUserProfile(Authentication authentication) {<br>        OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication;<br>        CustomOAuth2User user = (CustomOAuth2User) token.getPrincipal();<br>        <br>        UserProfile profile = UserProfile.builder()<br>            .email(user.getEmail())<br>            .name(user.getName())<br>            .provider(user.getRegistrationId())<br>            .build();<br>            <br>        return ResponseEntity.ok(profile);<br>    }<br><br>    @GetMapping(&quot;/admin/users&quot;)<br>    @PreAuthorize(&quot;hasRole(&#39;ADMIN&#39;)&quot;)<br>    public ResponseEntity&lt;List&lt;User&gt;&gt; getAllUsers() {<br>        return ResponseEntity.ok(userService.getAllUsers());<br>    }<br><br>    @GetMapping(&quot;/public/health&quot;)<br>    public ResponseEntity&lt;String&gt; healthCheck() {<br>        return ResponseEntity.ok(&quot;Service is running&quot;);<br>    }<br>}</pre><h4>Advanced OAuth2 Features</h4><h4>Custom Token Store</h4><pre>@Configuration<br>public class TokenStoreConfig {<br><br>    @Bean<br>    public TokenStore tokenStore() {<br>        return new JdbcTokenStore(dataSource());<br>    }<br><br>    @Bean<br>    public JwtAccessTokenConverter accessTokenConverter() {<br>        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();<br>        converter.setSigningKey(&quot;your-signing-key&quot;);<br>        return converter;<br>    }<br>}</pre><p><strong>OAuth2 Event Handling</strong></p><pre>@Component<br>public class OAuth2EventListener {<br><br>    @EventListener<br>    public void handleAuthenticationSuccess(AuthenticationSuccessEvent event) {<br>        if (event.getAuthentication() instanceof OAuth2AuthenticationToken) {<br>            OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) event.getAuthentication();<br>            log.info(&quot;User {} authenticated via {}&quot;, <br>                token.getName(), <br>                token.getAuthorizedClientRegistrationId());<br>        }<br>    }<br><br>    @EventListener<br>    public void handleAuthenticationFailure(AbstractAuthenticationFailureEvent event) {<br>        log.warn(&quot;Authentication failed: {}&quot;, event.getException().getMessage());<br>    }<br>}</pre><h4>Testing OAuth2 Implementation</h4><h4>Integration Tests</h4><pre>@SpringBootTest<br>@AutoConfigureTestDatabase<br>@TestPropertySource(properties = {<br>    &quot;spring.security.oauth2.client.registration.test.client-id=test-client&quot;,<br>    &quot;spring.security.oauth2.client.registration.test.client-secret=test-secret&quot;<br>})<br>class OAuth2IntegrationTest {<br><br>    @Autowired<br>    private TestRestTemplate restTemplate;<br><br>    @MockBean<br>    private OAuth2UserService&lt;OAuth2UserRequest, OAuth2User&gt; oauth2UserService;<br><br>    @Test<br>    void shouldAuthenticateWithValidToken() {<br>        OAuth2User mockUser = createMockOAuth2User();<br>        when(oauth2UserService.loadUser(any())).thenReturn(mockUser);<br><br>        ResponseEntity&lt;String&gt; response = restTemplate<br>            .withBasicAuth(&quot;test-client&quot;, &quot;test-secret&quot;)<br>            .getForEntity(&quot;/api/user/profile&quot;, String.class);<br><br>        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);<br>    }<br><br>    private OAuth2User createMockOAuth2User() {<br>        return new DefaultOAuth2User(<br>            Collections.singletonList(new SimpleGrantedAuthority(&quot;ROLE_USER&quot;)),<br>            Map.of(&quot;email&quot;, &quot;test@example.com&quot;, &quot;name&quot;, &quot;Test User&quot;),<br>            &quot;email&quot;<br>        );<br>    }<br>}</pre><p><strong>Conclusion:</strong><br>The combination of Spring Boot’s auto-configuration and OAuth2’s flexibility makes it an excellent choice for both simple and complex authentication scenarios. Start with basic implementations and gradually add advanced features as your application requirements grow.</p><h3>More resources:</h3><ol><li><a href="https://datatracker.ietf.org/doc/html/rfc6749">OAuth2 RFC 6749</a></li><li><a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT RFC 7519</a></li><li><a href="https://spring.io/guides/gs/securing-web">Spring Boot Security Documentation</a></li></ol><p>Note: To Understand best practices and security considerations, click <a href="https://medium.com/@roshanfarakate/oauth2-best-practices-and-security-considerations-edea3d05559f"><strong>Link</strong></a><strong>.</strong></p><p><strong><em>Thank You for Reading!</em></strong></p><p>✅<a href="https://medium.com/@roshanfarakate"> “Follow me on Medium to never miss an update!”</a></p><p><strong>If you found this content helpful, feel free to show your support with </strong>👏<strong> claps! </strong>😊<strong> Your encouragement keeps me motivated to share more insights.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d37cdd8f9b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>