<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajesh Mishra</title>
    <description>The latest articles on DEV Community by Rajesh Mishra (@rajesh1761).</description>
    <link>https://dev.to/rajesh1761</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F386291%2F3a705353-b889-4de6-8aac-ee5b91fcf935.png</url>
      <title>DEV Community: Rajesh Mishra</title>
      <link>https://dev.to/rajesh1761</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajesh1761"/>
    <language>en</language>
    <item>
      <title>Spring AI vs LangChain4j comparison which to use 2026 — Complete Guide 2026</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Sat, 31 Oct 2026 13:59:25 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-ai-vs-langchain4j-comparison-which-to-use-2026-complete-guide-2026-2ddp</link>
      <guid>https://dev.to/rajesh1761/spring-ai-vs-langchain4j-comparison-which-to-use-2026-complete-guide-2026-2ddp</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/spring-ai-vs-langchain4j-comparison-which-to-use-2026-complete-guide-2026/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Introduction Artificial‑intelligence integration has become a core part of modern Java applications. In 2026 the two most talked‑about ecosystems for building LLM‑driven services are Spring AI and LangChain4j . Both projects aim to simplify prompt engineering, model orchestration, and tool integration, yet they differ in philosophy, ecosystem fit, and runtime characteristics. This post provides a quick‑look overview to help you decide which stack aligns with your project goals. Aspect Spring AI (2026) LangChain4j (2026) Primary Audience Spring‑centric developers, enterprise teams, microservice architects LLM‑first developers, polyglot teams, rapid‑prototype enthusiasts Core Integration Model Spring Bean lifecycle, @Configuration , ApplicationContext Fluent builder pattern, functional pipel&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/spring-ai-vs-langchain4j-comparison-which-to-use-2026-complete-guide-2026/" rel="noopener noreferrer"&gt;Spring AI vs LangChain4j comparison which to use 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/spring-ai-vs-langchain4j-comparison-which-to-use-2026-complete-guide-2026/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>LangChain4j Tutorial: Building AI Apps in Java – Complete Guide 2026</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Thu, 29 Oct 2026 14:45:24 +0000</pubDate>
      <link>https://dev.to/rajesh1761/langchain4j-tutorial-building-ai-apps-in-java-complete-guide-2026-3fi</link>
      <guid>https://dev.to/rajesh1761/langchain4j-tutorial-building-ai-apps-in-java-complete-guide-2026-3fi</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/langchain4j-tutorial-building-ai-apps-in-java-complete-guide-2026/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR LangChain4j is the 2026‑ready Java library that lets you stitch together LLMs, vector stores, agents, and tool‑calling pipelines with just a few lines of code. Below is a rapid‑fire overview of what the framework provides, the essential steps to spin up a Java AI app, and the key takeaways from this guide. Feature What It Does Typical Use‑Case LLM Wrapper Unified API for OpenAI, Anthropic, Gemini, Ollama, etc. Chatbots, text generation, summarisation. Prompt Templates Typed, reusable templates with Jinja‑style variables. Dynamic queries, few‑shot prompting. Memory &amp;amp; Chains Conversation buffers, retrieval‑augmented generation (RAG) pipelines. Customer support agents, knowledge‑base assistants. Vector Store Connectors Plug‑and‑play adapters for Pinecone, Qdrant, Milvus, Chroma. Semanti&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/langchain4j-tutorial-building-ai-apps-in-java-complete-guide-2026/" rel="noopener noreferrer"&gt;LangChain4j tutorial building AI apps in Java complete guide 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/langchain4j-tutorial-building-ai-apps-in-java-complete-guide-2026/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Spring AI Complete Tutorial: Getting Started Guide 2026</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Tue, 27 Oct 2026 13:44:39 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-ai-complete-tutorial-getting-started-guide-2026-2b2g</link>
      <guid>https://dev.to/rajesh1761/spring-ai-complete-tutorial-getting-started-guide-2026-2b2g</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/spring-ai-complete-tutorial-getting-started-guide-2026/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR Spring AI is the Spring ecosystem’s unified abstraction layer for generative AI services (LLMs, embeddings, vector stores, chat‑agents, etc.). In 2026 it matters because: It hides vendor‑specific APIs (OpenAI, Anthropic, Azure, AWS Bedrock, etc.) behind a single, type‑safe Spring interface. It integrates natively with Spring Boot, Spring Cloud, and the new spring-boot-starter-ai starter, enabling rapid prototyping and production‑grade observability. It supports the emerging AI‑first architecture patterns: RAG pipelines, tool‑calling agents, and multimodal workflows. The tutorial walks you through building a complete end‑to‑end Spring Boot application that: Configures an LLM (e.g., OpenAI GPT‑4o) via Spring properties. Creates an EmbeddingModel and stores vectors in a PostgreSQL‑PGVec&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/spring-ai-complete-tutorial-getting-started-guide-2026/" rel="noopener noreferrer"&gt;Spring AI complete tutorial getting started guide 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/spring-ai-complete-tutorial-getting-started-guide-2026/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Hybrid Search in 2026: Combining Keyword and Semantic Search – A Complete Tutorial</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Sun, 25 Oct 2026 12:51:21 +0000</pubDate>
      <link>https://dev.to/rajesh1761/hybrid-search-in-2026-combining-keyword-and-semantic-search-a-complete-tutorial-3gjf</link>
      <guid>https://dev.to/rajesh1761/hybrid-search-in-2026-combining-keyword-and-semantic-search-a-complete-tutorial-3gjf</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/hybrid-search-in-2026-combining-keyword-and-semantic-search-a-complete-tutorial/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR Hybrid search merges BM25 keyword matching with vector similarity from modern LLM embeddings. The result is a relevance boost, better handling of synonyms and intent, while retaining the speed and interpretability of classic inverted indexes. Follow the three‑step workflow below to implement → test → deploy a production‑ready hybrid search pipeline. Component Keyword (BM25) Semantic (Vector) Hybrid Strength Exact term matching, fast posting‑list look‑ups Synonym/intent capture, robust to typo Best‑of‑both worlds – higher NDCG, lower latency than pure vector Typical Score BM25 score (float) Cosine similarity (float) Weighted sum: α·BM25 + (1‑α)·cosine Index Size ~30 GB for 10 M docs ~120 GB (768‑dim float16) Both stored side‑by‑side; compression tricks keep total Implementation sketch&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/hybrid-search-in-2026-combining-keyword-and-semantic-search-a-complete-tutorial/" rel="noopener noreferrer"&gt;Hybrid search combining keyword and semantic search tutorial 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/hybrid-search-in-2026-combining-keyword-and-semantic-search-a-complete-tutorial/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Spring Security role based access control RBAC tutorial — Complete Guide</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Sun, 25 Oct 2026 12:20:08 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-security-role-based-access-control-rbac-tutorial-complete-guide-2efk</link>
      <guid>https://dev.to/rajesh1761/spring-security-role-based-access-control-rbac-tutorial-complete-guide-2efk</guid>
      <description>&lt;h1&gt;
  
  
  Spring Security role based access control RBAC tutorial — Complete Guide
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A practical, in-depth guide to Spring Security role based access control RBAC tutorial with examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  INTRO
&lt;/h2&gt;

&lt;p&gt;Most Spring Boot applications ship with a default security configuration that either leaves every endpoint open or locks everything behind a generic login. In real‑world services, you rarely have a single “admin” role that can do everything; you need fine‑grained permissions that map to business concepts like &lt;em&gt;MANAGER&lt;/em&gt;, &lt;em&gt;CUSTOMER_SUPPORT&lt;/em&gt;, or &lt;em&gt;API_CONSUMER&lt;/em&gt;. Without a clear RBAC strategy, you end up scattering &lt;code&gt;if&lt;/code&gt; checks throughout controllers, duplicating logic, and exposing sensitive data when a role is added or changed.&lt;/p&gt;

&lt;p&gt;Spring Security gives you the building blocks—&lt;code&gt;GrantedAuthority&lt;/code&gt;, &lt;code&gt;@PreAuthorize&lt;/code&gt;, and the &lt;code&gt;HttpSecurity&lt;/code&gt; DSL—but stitching them together into a maintainable RBAC layer is non‑trivial. You have to decide where roles live (in the database, LDAP, or JWT claims), how they are loaded into the security context, and how to enforce them consistently across REST endpoints and method calls. The guide linked below walks through every decision point, shows you how to avoid common pitfalls, and ends with a production‑ready configuration you can drop into any Spring Boot project.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT YOU'LL LEARN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to model roles and permissions in a relational database and map them to Spring Security’s &lt;code&gt;GrantedAuthority&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Configuring &lt;code&gt;UserDetailsService&lt;/code&gt; to load a user’s authorities efficiently with JPA/Hibernate.&lt;/li&gt;
&lt;li&gt;Securing REST endpoints with both URL‑based rules (&lt;code&gt;http.authorizeRequests()&lt;/code&gt;) and method‑level annotations (&lt;code&gt;@PreAuthorize&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Dynamically updating a user’s roles at runtime without restarting the application.&lt;/li&gt;
&lt;li&gt;Testing RBAC policies using Spring’s &lt;code&gt;@WithMockUser&lt;/code&gt; and MockMvc.&lt;/li&gt;
&lt;li&gt;Pitfalls to watch out for: role hierarchy, authority duplication, and caching stale permissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A SHORT CODE SNIPPET
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@EnableWebSecurity&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecurityConfig&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;WebSecurityConfigurerAdapter&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="nd"&gt;@Autowired&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;CustomUserDetailsService&lt;/span&gt; &lt;span class="n"&gt;userDetailsService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AuthenticationManagerBuilder&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;userDetailsService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userDetailsService&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BCryptPasswordEncoder&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpSecurity&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;csrf&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;disable&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;authorizeRequests&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/public/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpMethod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;GET&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"/api/orders/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;hasAnyRole&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"ADMIN"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpMethod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"/api/orders/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;hasRole&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ADMIN"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;authenticated&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;httpBasic&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The snippet shows a concise, production‑oriented security filter chain: public endpoints are open, read‑only order APIs accept both &lt;em&gt;USER&lt;/em&gt; and &lt;em&gt;ADMIN&lt;/em&gt;, while creation requires &lt;em&gt;ADMIN&lt;/em&gt;. The heavy lifting—loading roles from the database—is delegated to &lt;code&gt;CustomUserDetailsService&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  KEY TAKEAWAYS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Define &lt;strong&gt;roles&lt;/strong&gt; and &lt;strong&gt;permissions&lt;/strong&gt; as first‑class entities; never hard‑code strings throughout your codebase.&lt;/li&gt;
&lt;li&gt;Leverage both &lt;strong&gt;URL‑level&lt;/strong&gt; and &lt;strong&gt;method‑level&lt;/strong&gt; security to keep the access matrix readable and testable.&lt;/li&gt;
&lt;li&gt;Keep the authority cache in sync with the data store; a simple &lt;code&gt;@CacheEvict&lt;/code&gt; on role updates prevents stale permissions.&lt;/li&gt;
&lt;li&gt;Comprehensive unit and integration tests are essential; they catch mis‑configured antMatchers before they hit production.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 &lt;strong&gt;Read the complete guide with step-by-step examples, common mistakes, and production tips:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://howtostartprogramming.in/spring-security-role-based-access-control-rbac-tutorial-complete-guide/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=cross-post" rel="noopener noreferrer"&gt;Spring Security role based access control RBAC tutorial — Complete Guide&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Spring Security API key authentication for REST APIs tutorial — Complete Guide</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Sat, 24 Oct 2026 11:51:07 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-security-api-key-authentication-for-rest-apis-tutorial-complete-guide-4f94</link>
      <guid>https://dev.to/rajesh1761/spring-security-api-key-authentication-for-rest-apis-tutorial-complete-guide-4f94</guid>
      <description>&lt;h1&gt;
  
  
  Spring Security API key authentication for REST APIs tutorial — Complete Guide
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A practical, in-depth guide to Spring Security API key authentication for REST APIs tutorial with examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  INTRO
&lt;/h2&gt;

&lt;p&gt;Every day we ship micro‑services that expose JSON endpoints to internal tools, mobile apps, or third‑party partners. The default Spring Security setup assumes a session‑based, form‑login flow—perfect for web UIs but a poor fit for stateless APIs. When you try to protect a REST endpoint with the out‑of‑the‑box configuration, you quickly hit a wall: CSRF tokens, redirects, and &lt;code&gt;HttpSession&lt;/code&gt; objects start leaking into your API contract, forcing clients to handle cookies they never asked for.&lt;/p&gt;

&lt;p&gt;The pragmatic solution is to replace the heavyweight OAuth dance or JWT boilerplate with a simple API key. An API key is just a secret string that a client includes in each request, typically via a header. It’s easy to generate, rotate, and audit, and it works flawlessly with Spring’s filter chain. The challenge isn’t the concept—it’s wiring the key check into Spring Security without breaking the rest of your configuration, handling missing or malformed keys gracefully, and keeping the implementation testable.&lt;/p&gt;

&lt;p&gt;If you’ve ever written a custom &lt;code&gt;OncePerRequestFilter&lt;/code&gt; that felt like a hack, or you’ve been forced to expose your endpoints without any protection because “security is too hard,” this guide will show you a clean, production‑ready way to integrate API key authentication directly into Spring Security’s authentication manager.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT YOU'LL LEARN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to define a lightweight &lt;code&gt;AuthenticationToken&lt;/code&gt; that represents an API key and plug it into Spring’s &lt;code&gt;AuthenticationProvider&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Configuring the security filter chain to intercept requests, extract the key from a custom header, and delegate to the provider.&lt;/li&gt;
&lt;li&gt;Storing API keys securely using Spring Data JPA, with hashing and rotation strategies.&lt;/li&gt;
&lt;li&gt;Writing unit and integration tests for the filter, provider, and controller layers without starting a full server.&lt;/li&gt;
&lt;li&gt;Common pitfalls such as leaking keys in logs, handling multiple keys per client, and mixing API key auth with other mechanisms.&lt;/li&gt;
&lt;li&gt;Production hardening tips: rate limiting, revocation, and monitoring key usage with Spring Actuator.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A SHORT CODE SNIPPET
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Simple Authentication token that holds the raw API key&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApiKeyAuthenticationToken&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AbstractAuthenticationToken&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;ApiKeyAuthenticationToken&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;setAuthenticated&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;ApiKeyAuthenticationToken&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;GrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;authorities&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authorities&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;setAuthenticated&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nf"&gt;getCredentials&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nf"&gt;getPrincipal&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This token is the cornerstone of the authentication flow. The filter extracts the header, creates an unauthenticated instance, and hands it to the provider. If the key matches a stored record, the provider returns an authenticated token populated with the user’s authorities.&lt;/p&gt;

&lt;h2&gt;
  
  
  KEY TAKEAWAYS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leverage Spring’s extensibility&lt;/strong&gt;: By creating a custom &lt;code&gt;AuthenticationToken&lt;/code&gt; and &lt;code&gt;AuthenticationProvider&lt;/code&gt;, you keep the API key logic out of controllers and let Spring handle the heavy lifting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never store raw keys&lt;/strong&gt;: Hash the API key (e.g., BCrypt) before persisting, and compare hashes during authentication to mitigate leakage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail fast and stay silent&lt;/strong&gt;: Return &lt;code&gt;401 Unauthorized&lt;/code&gt; without revealing whether the key was missing or invalid; this prevents enumeration attacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make it testable&lt;/strong&gt;: Isolate the filter, provider, and repository so you can unit‑test each piece with mock requests and verify behavior under edge cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 &lt;strong&gt;Read the complete guide with step-by-step examples, common mistakes, and production tips:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://howtostartprogramming.in/spring-security-api-key-authentication-for-rest-apis-tutorial-complete-guide/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=cross-post" rel="noopener noreferrer"&gt;Spring Security API key authentication for REST APIs tutorial — Complete Guide&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Chunk Documents for RAG: Optimal Chunking Strategies 2026</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Fri, 23 Oct 2026 12:57:33 +0000</pubDate>
      <link>https://dev.to/rajesh1761/how-to-chunk-documents-for-rag-optimal-chunking-strategies-2026-3ehj</link>
      <guid>https://dev.to/rajesh1761/how-to-chunk-documents-for-rag-optimal-chunking-strategies-2026-3ehj</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/how-to-chunk-documents-for-rag-optimal-chunking-strategies-2026/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR – Optimal Document Chunking for RAG in 2026 Why chunking matters : RAG models retrieve and generate based on context windows. Proper chunking maximizes relevance, reduces hallucinations, and fits within token limits of modern LLMs (8‑32 k tokens in 2026). Goal Metric Impact Typical Token Range (2026) Retrieval precision ↑ Recall &amp;amp; ↓ Noise 200‑800 tokens Generation fidelity ↑ Coherence &amp;amp; ↓ Hallucination 400‑1200 tokens Cost efficiency ↓ API tokens × price Variable (depends on model) Top chunking strategies for 2026 (choose one or combine): Semantic Sliding Window – overlap = 15 % of chunk size; uses embeddings to keep topic continuity. Adaptive Token Budgeting – dynamically size chunks based on per‑section token density (e.g., tables vs. prose). Structure‑Aware Chunking – respects hea&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/how-to-chunk-documents-for-rag-optimal-chunking-strategies-2026/" rel="noopener noreferrer"&gt;How to chunk documents for RAG optimal chunking strategies 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/how-to-chunk-documents-for-rag-optimal-chunking-strategies-2026/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Spring Security method level security PreAuthorize Secured — Complete Guide</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Thu, 22 Oct 2026 12:46:13 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-security-method-level-security-preauthorize-secured-complete-guide-3nfd</link>
      <guid>https://dev.to/rajesh1761/spring-security-method-level-security-preauthorize-secured-complete-guide-3nfd</guid>
      <description>&lt;h1&gt;
  
  
  Spring Security method level security PreAuthorize Secured — Complete Guide
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A practical, in-depth guide to Spring Security method level security PreAuthorize Secured with examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  INTRO
&lt;/h2&gt;

&lt;p&gt;Every production‑grade Spring Boot service eventually hits the point where you need to protect &lt;em&gt;who&lt;/em&gt; can call &lt;em&gt;what&lt;/em&gt;. Relying solely on URL‑based filters leaves a dangerous blind spot: a malicious client can bypass the front‑door by invoking a service bean directly, or a teammate can accidentally expose a critical operation through a new endpoint. The result? Sensitive data leaks, unauthorized state changes, and a nightmare when you try to audit who did what.&lt;/p&gt;

&lt;p&gt;Method‑level security closes that gap by moving the access decision right to the business logic. With annotations like &lt;code&gt;@PreAuthorize&lt;/code&gt; and &lt;code&gt;@Secured&lt;/code&gt;, you declare intent next to the code that matters, and Spring’s expression language lets you compose complex rules without scattering if‑else checks throughout the codebase. The trade‑off is a bit of configuration and a learning curve around SpEL, but the payoff is a clean, declarative security model that scales with your domain.&lt;/p&gt;

&lt;p&gt;If you’ve ever wrestled with “who can delete a user?” or “why does my admin endpoint still reject a manager token?”, this guide will give you a concrete, end‑to‑end recipe for getting method security right the first time.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT YOU'LL LEARN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The difference between &lt;code&gt;@PreAuthorize&lt;/code&gt; and &lt;code&gt;@Secured&lt;/code&gt;&lt;/strong&gt; – when to pick one over the other and how they interact with Spring’s &lt;code&gt;MethodSecurityExpressionHandler&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting up global method security&lt;/strong&gt; – the minimal &lt;code&gt;@EnableGlobalMethodSecurity&lt;/code&gt; flags you need, and how to avoid the common pitfall of forgetting to enable proxy‑based security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Writing expressive SpEL expressions&lt;/strong&gt; – from simple role checks (&lt;code&gt;hasRole('ADMIN')&lt;/code&gt;) to dynamic permission lookups (&lt;code&gt;@permissionService.hasAccess(#id, authentication)&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrating custom permission evaluators&lt;/strong&gt; – plug in your own &lt;code&gt;PermissionEvaluator&lt;/code&gt; or &lt;code&gt;MethodSecurityExpressionRoot&lt;/code&gt; to enforce domain‑specific rules without polluting controllers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing method security&lt;/strong&gt; – unit‑test strategies with &lt;code&gt;@WithMockUser&lt;/code&gt;, &lt;code&gt;@WithSecurityContext&lt;/code&gt;, and the Spring Test Security module to guarantee your annotations behave as expected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production hardening tips&lt;/strong&gt; – caching decisions, handling &lt;code&gt;AccessDeniedException&lt;/code&gt; globally, and avoiding proxy‑target class pitfalls in AOP‑heavy applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A SHORT CODE SNIPPET
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DocumentService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="c1"&gt;// Only users with ROLE_EDITOR or the owner of the document can update it&lt;/span&gt;
&lt;span class="nd"&gt;@PreAuthorize&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hasRole('EDITOR') or @docPermission.checkOwner(#docId, authentication)"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Document&lt;/span&gt; &lt;span class="nf"&gt;updateDocument&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;docId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;DocumentDto&lt;/span&gt; &lt;span class="n"&gt;dto&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="nc"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;docId&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;orElseThrow&lt;/span&gt;&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundException&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// business logic …&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this tiny fragment the security rule lives right next to the method signature. The custom bean &lt;code&gt;docPermission&lt;/code&gt; encapsulates the “owner” check, keeping the expression readable while still leveraging full Spring DI.&lt;/p&gt;

&lt;h2&gt;
  
  
  KEY TAKEAWAYS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Method‑level annotations give you &lt;em&gt;defense in depth&lt;/em&gt; by protecting the service layer, not just the web layer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PreAuthorize&lt;/code&gt; offers full SpEL power; &lt;code&gt;@Secured&lt;/code&gt; is a lightweight alternative for simple role checks.&lt;/li&gt;
&lt;li&gt;A custom &lt;code&gt;PermissionEvaluator&lt;/code&gt; or expression root lets you express domain concepts (ownership, hierarchy, time‑based access) without leaking them into controllers.&lt;/li&gt;
&lt;li&gt;Proper testing and proxy configuration are essential; a mis‑configured &lt;code&gt;@EnableGlobalMethodSecurity&lt;/code&gt; silently disables all your annotations.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 &lt;strong&gt;Read the complete guide with step-by-step examples, common mistakes, and production tips:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://howtostartprogramming.in/spring-security-method-level-security-preauthorize-secured-complete-guide/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=cross-post" rel="noopener noreferrer"&gt;Spring Security method level security PreAuthorize Secured — Complete Guide&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Semantic Search with Java Spring Boot Embeddings: A 2026 Tutorial</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Wed, 21 Oct 2026 13:19:30 +0000</pubDate>
      <link>https://dev.to/rajesh1761/semantic-search-with-java-spring-boot-embeddings-a-2026-tutorial-1k0j</link>
      <guid>https://dev.to/rajesh1761/semantic-search-with-java-spring-boot-embeddings-a-2026-tutorial-1k0j</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/semantic-search-with-java-spring-boot-embeddings-a-2026-tutorial/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR This snapshot walks you through building a semantic‑search API with Spring Boot (2026). You’ll: Bootstrap a spring-boot-starter-web project. Call the 2026 LLM embeddings endpoint (e.g., &lt;a href="https://api.llm2026.com/v1/embeddings" rel="noopener noreferrer"&gt;https://api.llm2026.com/v1/embeddings&lt;/a&gt; ) to turn text into dense vectors. Persist those vectors in a vector‑DB (e.g., Qdrant or Milvus ). Expose a /search REST endpoint that receives a query, generates its embedding, runs a k‑NN lookup, and returns the most semantically similar documents. Step Tool / Library Key Code Snippet 1⃣ Project Setup Spring Initializr (Web, Lombok, Validation)  org.springframework.boot spring-boot-starter-web  2⃣ Embedding Service WebClient (reactive HTTP client) @Service public class EmbeddingService { privat&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/semantic-search-with-java-spring-boot-embeddings-a-2026-tutorial/" rel="noopener noreferrer"&gt;Semantic search with Java Spring Boot embeddings tutorial 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/semantic-search-with-java-spring-boot-embeddings-a-2026-tutorial/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Spring Security session management and remember me tutorial — Complete Guide</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Tue, 20 Oct 2026 12:31:50 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-security-session-management-and-remember-me-tutorial-complete-guide-20a8</link>
      <guid>https://dev.to/rajesh1761/spring-security-session-management-and-remember-me-tutorial-complete-guide-20a8</guid>
      <description>&lt;h1&gt;
  
  
  Spring Security session management and remember me tutorial — Complete Guide
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A practical, in-depth guide to Spring Security session management and remember me tutorial with examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  INTRO
&lt;/h2&gt;

&lt;p&gt;Every production‑grade Spring Boot app eventually hits the “session” wall. You might have started with a simple form login, but as traffic grows you’ll notice users getting logged out unexpectedly, concurrent logins being abused, or, worse, session fixation attacks slipping through the cracks. The default Spring Security configuration protects you against the most obvious threats, yet it leaves critical knobs untouched: session concurrency limits, custom session expiration policies, and the infamous “remember‑me” cookie that can become a backdoor if mis‑configured.&lt;/p&gt;

&lt;p&gt;Ignoring these knobs isn’t just a theoretical risk. Real‑world incidents—like users being forced off a shared workstation because another device silently hijacked their session—are often traced back to lax session management. Meanwhile, developers love the convenience of “keep me logged in” but end up storing plain tokens or using the default 2‑week cookie without any persistence strategy, opening the door to replay attacks. The right balance between security and usability requires a deliberate, code‑first approach, and that’s exactly what the full guide walks you through.&lt;/p&gt;

&lt;p&gt;In this teaser, I’ll highlight why you should care about session fixation, concurrency control, and a robust remember‑me implementation before you ship your next microservice or monolith. The goal isn’t to replace Spring Security’s defaults but to extend them with production‑ready patterns that keep users safe without sacrificing the smooth “stay signed in” experience they expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT YOU'LL LEARN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to enforce session fixation protection and rotate session IDs after authentication.&lt;/li&gt;
&lt;li&gt;Configuring concurrent session control: limiting logins per user and handling session expiration events.&lt;/li&gt;
&lt;li&gt;Implementing a custom &lt;code&gt;SessionRegistry&lt;/code&gt; to track active sessions across a distributed cluster.&lt;/li&gt;
&lt;li&gt;Setting up a persistent “remember‑me” token store (JDBC, Redis, or JPA) instead of the insecure default.&lt;/li&gt;
&lt;li&gt;Securing the remember‑me cookie with &lt;code&gt;HttpOnly&lt;/code&gt;, &lt;code&gt;Secure&lt;/code&gt;, and same‑site attributes.&lt;/li&gt;
&lt;li&gt;Common pitfalls—such as mixing stateless JWT filters with stateful session management—and how to avoid them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A SHORT CODE SNIPPET
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@EnableWebSecurity&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecurityConfig&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;WebSecurityConfigurerAdapter&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="nd"&gt;@Autowired&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;DataSource&lt;/span&gt; &lt;span class="n"&gt;dataSource&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// for persistent token repository&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpSecurity&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;http&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;formLogin&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;loginPage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/login"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sessionManagement&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sessionFixation&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;migrateSession&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// rotate ID on login&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;maximumSessions&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// one session per user&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;maxSessionsPreventsLogin&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// allow new login, expire old&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sessionRegistry&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sessionRegistry&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rememberMe&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mySuperSecretKey"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;tokenValiditySeconds&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1209600&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 14 days&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;tokenRepository&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;persistentTokenRepository&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;SessionRegistry&lt;/span&gt; &lt;span class="nf"&gt;sessionRegistry&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;SessionRegistryImpl&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;PersistentTokenRepository&lt;/span&gt; &lt;span class="nf"&gt;persistentTokenRepository&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="nc"&gt;JdbcTokenRepositoryImpl&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;JdbcTokenRepositoryImpl&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setDataSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataSource&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This snippet shows the essential pieces: session fixation protection, a single‑session policy, and a JDBC‑backed remember‑me token store—all configurable in a few fluent calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  KEY TAKEAWAYS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Never trust the default session cookie&lt;/strong&gt; – always enable session fixation protection and consider rotating IDs on every successful authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrent session control is a first‑line defense&lt;/strong&gt; against credential sharing and session hijacking; a custom &lt;code&gt;SessionRegistry&lt;/code&gt; lets you monitor and revoke sessions centrally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Persisted remember‑me tokens are far safer&lt;/strong&gt; than the in‑memory default; they let you invalidate tokens on password change or logout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cookie attributes matter&lt;/strong&gt; – &lt;code&gt;HttpOnly&lt;/code&gt;, &lt;code&gt;Secure&lt;/code&gt;, and &lt;code&gt;SameSite=Strict/Lax&lt;/code&gt; dramatically reduce the attack surface for XSS and CSRF exploits.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 &lt;strong&gt;Read the complete guide with step-by-step examples, common mistakes, and production tips:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://howtostartprogramming.in/spring-security-session-management-and-remember-me-tutorial-complete-guide/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=cross-post" rel="noopener noreferrer"&gt;Spring Security session management and remember me tutorial — Complete Guide&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Chroma DB Tutorial 2026: Building a Local Vector Database for AI Apps</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Mon, 19 Oct 2026 15:07:57 +0000</pubDate>
      <link>https://dev.to/rajesh1761/chroma-db-tutorial-2026-building-a-local-vector-database-for-ai-apps-4ll4</link>
      <guid>https://dev.to/rajesh1761/chroma-db-tutorial-2026-building-a-local-vector-database-for-ai-apps-4ll4</guid>
      <description>&lt;p&gt;This is a summary of the full tutorial published on &lt;a href="https://howtostartprogramming.in/chroma-db-tutorial-2026-building-a-local-vector-database-for-ai-apps/" rel="noopener noreferrer"&gt;howtostartprogramming.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR A lightning‑fast guide to getting Chroma DB up and running locally for AI apps in 2026. Install, spin up a collection, index your embeddings, and query vectors—all in a few commands. Step Command / Code What it does 1⃣ Install pip install chromadb Pulls the latest Chroma DB package (v0.5+ as of 2026) with all native dependencies. 2⃣ Initialise client import chromadb client = chromadb.PersistentClient(path="./chroma_data") Creates a local SQLite‑backed store at ./chroma_data . 3⃣ Create collection collection = client.get_or_create_collection( name="my_docs", metadata={"description": "Vector store for knowledge‑base docs"} ) Sets up a namespace (collection) where vectors and metadata live. 4⃣ Index embeddings ids = [f"doc_{i}" for i in range(len(texts))] embeddings = model.encode(texts&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 Read the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://howtostartprogramming.in/chroma-db-tutorial-2026-building-a-local-vector-database-for-ai-apps/" rel="noopener noreferrer"&gt;Chroma DB tutorial local vector database for AI apps 2026 — Full Guide with Code Examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Step-by-step code examples (copy-paste ready)&lt;/li&gt;
&lt;li&gt;✅ Complete working project (Spring Boot / Java)&lt;/li&gt;
&lt;li&gt;✅ Common mistakes + fixes&lt;/li&gt;
&lt;li&gt;✅ Production tips and benchmarks&lt;/li&gt;
&lt;li&gt;✅ FAQ section&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published on &lt;a href="https://howtostartprogramming.in/chroma-db-tutorial-2026-building-a-local-vector-database-for-ai-apps/" rel="noopener noreferrer"&gt;How to Start Programming&lt;/a&gt; — practical AI and Java tutorials for developers.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>2026</category>
      <category>machinelearning</category>
      <category>java</category>
    </item>
    <item>
      <title>Spring Security custom UserDetailsService with database example — Complete Guide</title>
      <dc:creator>Rajesh Mishra</dc:creator>
      <pubDate>Mon, 19 Oct 2026 14:19:17 +0000</pubDate>
      <link>https://dev.to/rajesh1761/spring-security-custom-userdetailsservice-with-database-example-complete-guide-52hb</link>
      <guid>https://dev.to/rajesh1761/spring-security-custom-userdetailsservice-with-database-example-complete-guide-52hb</guid>
      <description>&lt;h1&gt;
  
  
  Spring Security custom UserDetailsService with database example — Complete Guide
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A practical, in-depth guide to Spring Security custom UserDetailsService with database example with examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  INTRO
&lt;/h2&gt;

&lt;p&gt;When you start wiring Spring Security into a real‑world application, the default in‑memory user store quickly becomes a dead end. Hard‑coding usernames, passwords, and roles works for demos, but it collapses under the weight of multi‑tenant data, password‑policy changes, and audit requirements. The moment you need to pull credentials from a relational database, you’re forced to confront a gap in the official docs: how to bridge Spring Security’s &lt;code&gt;UserDetailsService&lt;/code&gt; contract with JPA/Hibernate without reinventing the wheel.&lt;/p&gt;

&lt;p&gt;That gap isn’t just academic. In production, a mis‑configured &lt;code&gt;UserDetailsService&lt;/code&gt; can expose plaintext passwords, bypass role hierarchies, or cause subtle bugs that only appear under load. A clean, testable implementation that respects Spring’s transaction boundaries and leverages the power of Spring Data is essential for any serious backend. This article teases the exact steps you need to get a robust, database‑backed authentication layer up and running.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT YOU'LL LEARN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to model &lt;code&gt;User&lt;/code&gt; and &lt;code&gt;Role&lt;/code&gt; entities that satisfy Spring Security’s &lt;code&gt;UserDetails&lt;/code&gt; contract.&lt;/li&gt;
&lt;li&gt;Building a custom &lt;code&gt;UserDetailsService&lt;/code&gt; that fetches users via Spring Data JPA, with proper exception handling.&lt;/li&gt;
&lt;li&gt;Configuring &lt;code&gt;PasswordEncoder&lt;/code&gt; and wiring the service into the security filter chain without XML.&lt;/li&gt;
&lt;li&gt;Writing unit tests for the service using &lt;code&gt;@DataJpaTest&lt;/code&gt; and Mockito to guarantee correctness.&lt;/li&gt;
&lt;li&gt;Common pitfalls (lazy loading, circular dependencies, and password migration) and how to avoid them.&lt;/li&gt;
&lt;li&gt;Production‑ready tips: caching user details, handling account lockout, and integrating with JWT or session‑based auth.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A SHORT CODE SNIPPET
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUserDetailsService&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;UserDetailsService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt; &lt;span class="n"&gt;userRepo&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;PasswordEncoder&lt;/span&gt; &lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;CustomUserDetailsService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UserRepository&lt;/span&gt; &lt;span class="n"&gt;userRepo&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;PasswordEncoder&lt;/span&gt; &lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;userRepo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userRepo&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;passwordEncoder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="nd"&gt;@Transactional&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;readOnly&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="nf"&gt;loadUserByUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;UsernameNotFoundException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userRepo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findByUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;orElseThrow&lt;/span&gt;&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UsernameNotFoundException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"User not found"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;springframework&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;security&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;core&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;userdetails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;User&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getUsername&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getPassword&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEnabled&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isLocked&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
&lt;span class="n"&gt;mapRolesToAuthorities&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRoles&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;GrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;mapRolesToAuthorities&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Role&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SimpleGrantedAuthority&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ROLE_"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;()))&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;collect&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Collectors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toSet&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  KEY TAKEAWAYS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A custom &lt;code&gt;UserDetailsService&lt;/code&gt; is the bridge between Spring Security and any persistent store; keep it thin and delegate data access to Spring Data repositories.&lt;/li&gt;
&lt;li&gt;Always annotate &lt;code&gt;loadUserByUsername&lt;/code&gt; with &lt;code&gt;@Transactional(readOnly = true)&lt;/code&gt; to avoid lazy‑loading exceptions during authentication.&lt;/li&gt;
&lt;li&gt;Encode passwords with a strong &lt;code&gt;PasswordEncoder&lt;/code&gt; (e.g., &lt;code&gt;BCryptPasswordEncoder&lt;/code&gt;) and never store raw credentials.&lt;/li&gt;
&lt;li&gt;Test the service in isolation and as part of the security configuration to catch integration bugs early.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 &lt;strong&gt;Read the complete guide with step-by-step examples, common mistakes, and production tips:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://howtostartprogramming.in/spring-security-custom-userdetailsservice-with-database-example-complete-guide/?utm_source=devto&amp;amp;utm_medium=post&amp;amp;utm_campaign=cross-post" rel="noopener noreferrer"&gt;Spring Security custom UserDetailsService with database example — Complete Guide&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
