moai-lang-java

1
0
Source

Java 21 LTS development specialist covering Spring Boot 3.3, virtual threads, pattern matching, and enterprise patterns. Use when building enterprise applications, microservices, or Spring projects.

Install

mkdir -p .claude/skills/moai-lang-java && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4270" && unzip -o skill.zip -d .claude/skills/moai-lang-java && rm skill.zip

Installs to .claude/skills/moai-lang-java

About this skill

Quick Reference (30 seconds)

Java 21 LTS Expert - Enterprise development with Spring Boot 3.3, Virtual Threads, and modern Java features.

Auto-Triggers: Java files with .java extension, build files including pom.xml, build.gradle, or build.gradle.kts

Core Capabilities:

  • Java 21 LTS: Virtual threads, pattern matching, record patterns, sealed classes
  • Spring Boot 3.3: REST controllers, services, repositories, WebFlux reactive
  • Spring Security 6: JWT authentication, OAuth2, role-based access control
  • JPA/Hibernate 7: Entity mapping, relationships, queries, transactions
  • JUnit 5: Unit testing, mocking, TestContainers integration
  • Build Tools: Maven 3.9, Gradle 8.5 with Kotlin DSL

Implementation Guide (5 minutes)

Java 21 LTS Features

Virtual Threads with Project Loom:

Use try-with-resources on Executors.newVirtualThreadPerTaskExecutor. Call IntStream.range from 0 to 10000 and forEach to submit tasks that sleep for one second and return the iteration value.

Structured Concurrency Preview Pattern:

Use try-with-resources on new StructuredTaskScope.ShutdownOnFailure. Fork tasks for fetching user and orders by calling scope.fork with lambda expressions. Call scope.join then throwIfFailed. Return new composite object with results from both task suppliers.

Pattern Matching for Switch:

Create describe method taking Object parameter. Use switch expression with cases for Integer i with guard condition i greater than 0 returning positive integer message, Integer i returning non-positive message, String s returning length message, List with wildcard returning size message, null returning null value, and default returning unknown type.

Record Patterns and Sealed Classes:

Define Point record with int x and int y. Define Rectangle record with Point topLeft and Point bottomRight. Create area method that uses switch with Rectangle pattern destructuring both Point components into variables, returning absolute value of width times height. Define sealed Shape interface permitting Circle and Rectangle. Implement Circle record with area method using PI times radius squared.

Spring Boot 3.3

REST Controller Pattern:

Create UserController with RestController annotation, RequestMapping for api/users, and RequiredArgsConstructor. Inject UserService. Create getUser method with GetMapping and PathVariable for id, returning ResponseEntity that maps findById result to ok or returns notFound. Create createUser method with PostMapping, Valid annotation, and RequestBody for CreateUserRequest. Create user, build URI location, return created response with body. Create deleteUser method with DeleteMapping that returns noContent or notFound based on service result.

Service Layer Pattern:

Create UserService with Service, RequiredArgsConstructor, and Transactional readOnly true annotations. Inject UserRepository and PasswordEncoder. Create findById method returning Optional. Create transactional create method that checks for duplicate email throwing DuplicateEmailException, builds User with builder pattern encoding password, and saves to repository.

Spring Security 6

Security Configuration Pattern:

Create SecurityConfig with Configuration and EnableWebSecurity annotations. Define filterChain Bean taking HttpSecurity. Configure authorizeHttpRequests with permitAll for public API paths, hasRole ADMIN for admin paths, and authenticated for all other requests. Configure oauth2ResourceServer with jwt default. Set sessionManagement to STATELESS and disable csrf. Define passwordEncoder Bean returning BCryptPasswordEncoder.

JPA/Hibernate Patterns

Entity Definition Pattern:

Create User entity with Entity and Table annotations. Add Lombok Getter, Setter, NoArgsConstructor, and Builder annotations. Define id with Id and GeneratedValue IDENTITY. Define name and email with Column nullable false, email also unique. Define status with Enumerated STRING. Define orders with OneToMany mappedBy user, cascade ALL, and orphanRemoval true.

Repository with Custom Queries Pattern:

Create UserRepository extending JpaRepository. Add findByEmail returning Optional. Add existsByEmail returning boolean. Add Query annotation for JPQL with LEFT JOIN FETCH for findByIdWithOrders using Param annotation. Add findByNameContainingIgnoreCase with Pageable for pagination.

DTOs as Records Pattern:

Create UserDto record with id, name, email, and status. Add static from factory method that constructs record from User entity. Create CreateUserRequest record with NotBlank and Size annotations for name, NotBlank and Email for email, NotBlank and Size min 8 for password.


Advanced Patterns

Virtual Threads Integration

Create AsyncUserService with Service and RequiredArgsConstructor annotations. Create fetchUserDetails method using StructuredTaskScope.ShutdownOnFailure in try-with-resources. Fork tasks for user and orders queries, join and throw if failed, return composite result. Create processUsersInParallel method using newVirtualThreadPerTaskExecutor and streaming user IDs to submit processing tasks.

Build Configuration

Maven 3.9 Pattern:

Define project with parent for spring-boot-starter-parent version 3.3.0. Set java.version property to 21. Add dependencies for spring-boot-starter-web and spring-boot-starter-data-jpa.

Gradle 8.5 Kotlin DSL Pattern:

Apply plugins for org.springframework.boot, io.spring.dependency-management, and java. Set toolchain languageVersion to 21. Add implementation dependencies for web and data-jpa starters, testImplementation for test starter.

Testing with JUnit 5

Unit Testing Pattern:

Create test class with ExtendWith MockitoExtension. Add Mock annotation for UserRepository. Add InjectMocks for UserService. Create shouldCreateUser test that stubs existsByEmail to return false and save to return user with id. Call service create and assertThat result id equals 1.

Integration Testing with TestContainers Pattern:

Create test class with Testcontainers and SpringBootTest annotations. Define static Container for PostgreSQL with postgres:16-alpine image. Add DynamicPropertySource to set datasource.url from container. Autowire repository. Create test that saves user and assertThat id isNotNull.


Context7 Integration

Library mappings for latest documentation:

  • spring-projects/spring-boot for Spring Boot 3.3 documentation
  • spring-projects/spring-framework for Spring Framework core
  • spring-projects/spring-security for Spring Security 6
  • hibernate/hibernate-orm for Hibernate 7 ORM patterns
  • junit-team/junit5 for JUnit 5 testing framework

Works Well With

  • moai-lang-kotlin for Kotlin interoperability and Spring Kotlin extensions
  • moai-domain-backend for REST API, GraphQL, and microservices architecture
  • moai-domain-database for JPA, Hibernate, and R2DBC patterns
  • moai-foundation-quality for JUnit 5, Mockito, and TestContainers integration
  • moai-infra-docker for JVM container optimization

Troubleshooting

Common Issues:

  • Version mismatch: Run java -version and check JAVA_HOME points to Java 21
  • Compilation errors: Run mvn clean compile -X or gradle build --info
  • Virtual thread issues: Ensure Java 21+ with --enable-preview if needed
  • JPA lazy loading: Use Transactional annotation or JOIN FETCH queries

Performance Tips:

  • Enable Virtual Threads by setting spring.threads.virtual.enabled to true
  • Use GraalVM Native Image for faster startup
  • Configure connection pooling with HikariCP

Advanced Documentation

For comprehensive reference materials:

  • reference.md for Java 21 features, Context7 mappings, and performance
  • examples.md for production-ready Spring Boot examples

Last Updated: 2026-01-11 Status: Production Ready (v1.1.0)

More by modu-ai

View all →

moai-translation-korean-multilingual

modu-ai

Enterprise-grade technical document translation system for Korean↔English↔Japanese with OpenAI GPT-4 integration, code block preservation, glossary management, and bilingual review workflows. Optimized for technical books and documentation under 50 pages with comprehensive quality validation including code preservation, terminology consistency, bilingual review, and automated testing.

752

moai-project-documentation

modu-ai

Enhanced project documentation with AI-powered features and Context7 integration

761

moai-platform-railway

modu-ai

Railway container deployment specialist covering Docker, multi-service architectures, persistent volumes, and auto-scaling. Use when deploying containerized full-stack applications, configuring multi-region deployments, or setting up persistent storage.

00

moai-domain-frontend

modu-ai

Frontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implementing components, optimizing frontend performance, or integrating state management.

00

moai-lang-flutter

modu-ai

Flutter 3.24+ / Dart 3.5+ development specialist covering Riverpod, go_router, and cross-platform patterns. Use when building cross-platform mobile apps, desktop apps, or web applications with Flutter.

10

moai-workflow-spec

modu-ai

SPEC workflow orchestration with EARS format, requirement clarification, and Plan-Run-Sync integration for MoAI-ADK development methodology

10

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

238775

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

182404

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

169268

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

194225

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

154189

rust-coding-skill

UtakataKyosui

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

157171

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.