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.config;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;

Messaging with Apache Kafka

java kafka messaging
by David Kumar 3 tabs
java
package com.example.demo.scheduled;

import com.example.demo.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;

Scheduled tasks with @Scheduled

java spring-boot scheduling
by David Kumar 2 tabs
java
package com.example.demo.dto;

import com.example.demo.validation.UniqueEmail;
import jakarta.validation.constraints.*;
import lombok.Data;

Validation with Bean Validation API

java validation bean-validation
by David Kumar 3 tabs
java
package com.example.demo.mapper;

import com.example.demo.dto.UserDTO;
import com.example.demo.model.User;
import org.mapstruct.*;

MapStruct for object mapping

java mapstruct dto
by David Kumar 3 tabs
java
package com.example.demo.config;

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;

Caching strategies with Spring Cache

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

import lombok.Builder;
import lombok.Data;
import java.time.LocalDateTime;

Builder pattern for object construction

java design-patterns builder
by David Kumar 2 tabs
java
package com.example.demo.config;

import com.example.demo.security.JwtAuthenticationFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;

Security with Spring Security and JWT

java spring-security jwt
by David Kumar 3 tabs
java
package com.example.demo.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

Microservices with Spring Cloud

java spring-cloud microservices
by David Kumar 3 tabs
java
package com.example.demo.service;

import com.example.demo.exception.ResourceNotFoundException;
import com.example.demo.model.User;
import com.example.demo.repository.UserRepository;
import org.junit.jupiter.api.BeforeEach;

JUnit 5 and Mockito testing strategies

java testing junit
by David Kumar 2 tabs
java
package com.example.demo.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

CompletableFuture for async programming

java async completablefuture
by David Kumar 1 tab
java
package com.example.demo.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;

Exception handling with @ControllerAdvice

java spring-boot exception-handling
by David Kumar 3 tabs
java
package com.example.demo.repository;

import com.example.demo.model.User;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.Predicate;

Spring Data JPA repository patterns

java spring-data jpa
by David Kumar 2 tabs