spring-boot

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.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
java
package com.example.demo.multitenancy;

public class TenantContext {
    private static final ThreadLocal<String> CURRENT_TENANT = new ThreadLocal<>();

    public static void setTenantId(String tenantId) {

Multi-tenancy for SaaS applications

java multi-tenancy saas
by David Kumar 4 tabs
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: user-service
  labels:
    app: user-service

Kubernetes deployment configuration

java kubernetes k8s
by David Kumar 5 tabs
java
package com.example.demo.controller;

import com.example.demo.model.User;
import com.example.demo.service.UserService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

Spring Boot REST API with CRUD operations

java spring-boot rest-api
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
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
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.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