kotlin-spring

Spring Boot with Kotlin - controllers, services, coroutines

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "kotlin-spring" with this command: npx skills add pluginagentmarketplace/custom-plugin-kotlin/pluginagentmarketplace-custom-plugin-kotlin-kotlin-spring

Kotlin Spring Skill

Idiomatic Spring Boot development with Kotlin.

Topics Covered

REST Controllers

@RestController
@RequestMapping("/api/v1/users")
class UserController(private val userService: UserService) {

    @GetMapping
    suspend fun findAll(): List<UserDTO> = userService.findAll()

    @GetMapping("/{id}")
    suspend fun findById(@PathVariable id: Long): UserDTO =
        userService.findById(id) ?: throw ResponseStatusException(NOT_FOUND)

    @PostMapping
    @ResponseStatus(CREATED)
    suspend fun create(@Valid @RequestBody request: CreateUserRequest) =
        userService.create(request)
}

Coroutines Integration

@Service
class UserService(private val repository: UserRepository) {
    suspend fun findAll() = withContext(Dispatchers.IO) {
        repository.findAll().map { it.toDTO() }
    }
}

Data JPA

@Entity
@Table(name = "users")
class User(
    @Id @GeneratedValue val id: Long = 0,
    @Column(nullable = false) val email: String,
    @Column(nullable = false) val name: String
)

interface UserRepository : JpaRepository<User, Long> {
    fun findByEmail(email: String): User?
}

Testing

@WebMvcTest(UserController::class)
class UserControllerTest {
    @Autowired lateinit var mockMvc: MockMvc
    @MockkBean lateinit var userService: UserService

    @Test
    fun `GET users returns list`() {
        every { userService.findAll() } returns listOf(user)
        mockMvc.get("/api/v1/users").andExpect { status { isOk() } }
    }
}

Troubleshooting

IssueResolution
@RequestBody nullAdd jackson-module-kotlin
Coroutines not workingEnable WebFlux or use blocking

Usage

Skill("kotlin-spring")

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

kotlin-compose

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-android

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-testing

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-ktor

No summary provided by upstream source.

Repository SourceNeeds Review