kotlin-springboot
Spring Boot development patterns and idioms tailored for Kotlin applications.
- Use primary constructors for dependency injection,
data classfor DTOs, and thekotlin-jpaplugin to automatically open entity classes without boilerplate. - Organize code by feature/domain rather than layer; leverage Kotlin's null-safety to clearly define optional vs. required entity fields.
- Apply
@ConfigurationPropertieswithdata classfor type-safe, immutable configuration; useapplication.ymland Spring Profiles for environment management. - Prefer Kotest and MockK for idiomatic testing; use
suspendfunctions and structured concurrency for non-blocking asynchronous code in controllers and services.
Spring Boot with Kotlin Best Practices
Your goal is to help me write high-quality, idiomatic Spring Boot applications using Kotlin.
Project Setup & Structure
- Build Tool: Use Maven (
pom.xml) or Gradle (build.gradle) with the Kotlin plugins (kotlin-maven-pluginororg.jetbrains.kotlin.jvm). - Kotlin Plugins: For JPA, enable the
kotlin-jpaplugin to automatically make entity classesopenwithout boilerplate. - Starters: Use Spring Boot starters (e.g.,
spring-boot-starter-web,spring-boot-starter-data-jpa) as usual. - Package Structure: Organize code by feature/domain (e.g.,
com.example.app.order,com.example.app.user) rather than by layer.
Dependency Injection & Components
- Primary Constructors: Always use the primary constructor for required dependency injection. It's the most idiomatic and concise approach in Kotlin.
- Immutability: Declare dependencies as
private valin the primary constructor. Prefervalovervareverywhere to promote immutability. - Component Stereotypes: Use
@Service,@Repository, and@RestControllerannotations just as you would in Java.
Configuration
More from github/awesome-copilot
git-commit
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
30.2Kgh-cli
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
21.2Kdocumentation-writer
Diátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure of the Diátaxis technical documentation authoring framework.
17.4Kprd
Generate high-quality Product Requirements Documents (PRDs) for software systems and AI-powered features. Includes executive summaries, user stories, technical specifications, and risk analysis.
17.4Kexcalidraw-diagram-generator
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
16.4Krefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
16.1K