David Kumar

38 code snips · on codesnips 5 months

Senior Java Developer with 12+ years building enterprise applications. Expert in Spring Boot, microservices, and cloud-native architectures. Passionate about clean code, design...

java
package com.example.demo.controller;

import com.example.demo.dto.UserDTO;
import com.example.demo.dto.v2.UserDTOV2;
import com.example.demo.service.UserService;
import org.springframework.web.bind.annotation.*;

API versioning strategies

java spring-boot api-versioning
by David Kumar 4 tabs
java
package com.example.starter.config;

import com.example.starter.properties.CustomProperties;
import com.example.starter.service.CustomService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;

Custom Spring Boot starters

java spring-boot starter
by David Kumar 4 tabs
java
package com.example.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;

CORS configuration for cross-origin requests

java spring-boot cors
by David Kumar 2 tabs
java
package com.example.demo.model;

import lombok.*;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

Lombok for reducing boilerplate code

java lombok boilerplate
by David Kumar 1 tab
java
package com.example.demo.service;

import com.example.demo.model.Order;
import com.example.demo.model.OrderItem;
import com.example.demo.model.User;
import com.example.demo.repository.OrderRepository;

Database transactions and isolation levels

java spring-boot transactions
by David Kumar 2 tabs
java
package com.example.demo.interceptor;

import io.github.bucket4j.Bandwidth;
import io.github.bucket4j.Bucket;
import io.github.bucket4j.Refill;
import jakarta.servlet.http.HttpServletRequest;

Rate limiting and API throttling

java rate-limiting bucket4j
by David Kumar 3 tabs
java
package com.example.demo.controller;

import com.example.demo.dto.FileMetadata;
import com.example.demo.service.FileStorageService;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;

File upload and download handling

java spring-boot file-upload
by David Kumar 2 tabs
java
package com.example.demo.controller;

import com.example.demo.dto.PageResponse;
import com.example.demo.dto.UserDTO;
import com.example.demo.model.User;
import com.example.demo.service.UserService;

Pagination and sorting with Spring Data

java spring-data pagination
by David Kumar 2 tabs
java
package com.example.demo.controller;

import com.example.demo.model.User;
import com.example.demo.service.ReactiveUserService;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

Reactive programming with WebFlux

java spring-webflux reactive
by David Kumar 2 tabs
java
package com.example.demo.service;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import org.springframework.stereotype.Service;

Actuator for production monitoring

java spring-boot actuator
by David Kumar 4 tabs
dockerfile
# Build stage
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /app

# Copy dependency definitions
COPY pom.xml .

Docker containerization for Spring Boot

java docker spring-boot
by David Kumar 3 tabs
xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <springProperty scope="context" name="APP_NAME" source="spring.application.name"/>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>

Logging with SLF4J and Logback

java logging slf4j
by David Kumar 2 tabs