·
Last changedVersion:
No hardening report available.
Your goal is to provide expert guidance on writing high-quality, idiomatic Spring Boot applications using Kotlin, following the practices defined in this document.
pom.xml) or Gradle (build.gradle) with the Kotlin plugins (kotlin-maven-plugin or org.jetbrains.kotlin.jvm).kotlin-spring plugin to automatically make Spring-annotated classes (@Service, @Component, etc.) open for AOP proxying (required for @Transactional and other Spring AOP features). For JPA, additionally enable the kotlin-jpa plugin to make entity classes open without boilerplate.spring-boot-starter-web, spring-boot-starter-data-jpa) as usual.com.example.app.order, com.example.app.user) rather than by layer.build.gradle(.kts) or pom.xml use https://. Never configure http:// repository URLs — they are vulnerable to MITM attacks that can substitute malicious artifacts.private val in the primary constructor. Prefer val over var everywhere to promote immutability.@Service, @Repository, and @RestController annotations just as you would in Java.application.yml for its readability and hierarchical structure.@ConfigurationProperties with data class to create immutable, type-safe configuration objects.application-dev.yml, application-prod.yml) to manage environment-specific configurations.data class for all DTOs. This provides equals(), hashCode(), toString(), and copy() for free and promotes immutability.@Valid, @NotNull, @Size) on your DTO data classes.@ControllerAdvice and @ExceptionHandler for consistent error responses.@Service classes.@Transactional on service methods. In Kotlin, this can be applied at class or function level. Important: Kotlin classes are final by default, which prevents Spring AOP from creating the proxies that @Transactional requires. Ensure the kotlin-spring compiler plugin is applied in your build — it automatically makes @Service, @Component, and other Spring-annotated classes open. Alternatively, apply the kotlin-allopen plugin explicitly. Without this, Spring AOP proxying silently fails on final Kotlin classes and transactions are not applied.open. It's highly recommended to use the kotlin-jpa compiler plugin to handle this automatically.?) to clearly define which entity fields are optional or required at the type level.JpaRepository or CrudRepository.logger.info("Processing user {}...", userId)) for performance and clarity.@WebMvcTest or @DataJpaTest to test specific parts of the application.org.testcontainers:testcontainers-bom) for consistency across modules.suspend functions: For non-blocking asynchronous code, use suspend functions in your controllers and services. Spring Boot has excellent support for coroutines.coroutineScope or supervisorScope to manage the lifecycle of coroutines.Need this version hardened?
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
—
—
MIT
HARDENING.md
LICENSE
SKILL.md