{"id":20028447,"url":"https://github.com/marx-wrld/kotlinwithspringboot","last_synced_at":"2026-05-10T13:36:34.763Z","repository":{"id":211484851,"uuid":"729220809","full_name":"Marx-wrld/KotlinWithSpringboot","owner":"Marx-wrld","description":"Kotlin with Spring Boot, web application for starters.","archived":false,"fork":false,"pushed_at":"2024-02-04T17:28:17.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T17:31:32.743Z","etag":null,"topics":["kotlin","rest-api","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Marx-wrld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-08T16:55:10.000Z","updated_at":"2023-12-28T14:47:46.000Z","dependencies_parsed_at":"2025-01-12T17:28:20.656Z","dependency_job_id":"a1837da8-d58f-45cb-8b66-468c217560fa","html_url":"https://github.com/Marx-wrld/KotlinWithSpringboot","commit_stats":null,"previous_names":["marx-wrld/kotlinwithspringboot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marx-wrld%2FKotlinWithSpringboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marx-wrld%2FKotlinWithSpringboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marx-wrld%2FKotlinWithSpringboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marx-wrld%2FKotlinWithSpringboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marx-wrld","download_url":"https://codeload.github.com/Marx-wrld/KotlinWithSpringboot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241460044,"owners_count":19966518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","rest-api","spring-boot"],"created_at":"2024-11-13T09:14:53.128Z","updated_at":"2026-05-10T13:36:29.674Z","avatar_url":"https://github.com/Marx-wrld.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KotlinWithSpringboot\nKotlin with Spring Boot, web application for starters.\n\n#### 1. Setting Up a Kotlin-Spring Boot Project\nYou can use Spring Initializer to set up a new project. Visit https://start.spring.io/ and fill in the necessary details:\n- Code editor: IntelliJ IDEA\n- Project: Gradle Project or Maven Project\n- Language: Kotlin\n- Spring Boot: Latest stable version\n- Project Metadata: Group, Artifact, Name, Description, etc.\n\nClick \"Generate\" to download the project zip file.\n\n#### 2. Extract and Open the Project\n\nExtract the downloaded zip file and open the project in your preferred IDE. If you're using IntelliJ IDEA, it has excellent support for Kotlin.\n\n#### 3. Create a Kotlin Data Class\n\nCreate a data class to represent your model. In `src/main/kotlin/com/example/demo/model`, create a file named `Book.kt`:\n\n```\npackage com.example.demo.model\n\ndata class Book(val id: Long, val title: String, val author: String)\n```\n#### 4. Create a Controller\n\nCreate a controller to handle HTTP requests. In `src/main/kotlin/com/example/demo/controller`, create a file named `BookController.kt`\n\n```\npackage com.example.demo.controller\n\nimport com.example.demo.model.Book\nimport org.springframework.web.bind.annotation.*\n\n@RestController\n@RequestMapping(\"/api/books\")\nclass BookController {\n\n    private val books = mutableListOf\u003cBook\u003e()\n\n    @GetMapping\n    fun getAllBooks(): List\u003cBook\u003e {\n        return books\n    }\n\n    @GetMapping(\"/{id}\")\n    fun getBookById(@PathVariable id: Long): Book? {\n        return books.find { it.id == id }\n    }\n\n    @PostMapping\n    fun addBook(@RequestBody book: Book): Book {\n        books.add(book)\n        return book\n    }\n\n    @PutMapping(\"/{id}\")\n    fun updateBook(@PathVariable id: Long, @RequestBody updatedBook: Book): Book? {\n        val index = books.indexOfFirst { it.id == id }\n        if (index != -1) {\n            books[index] = updatedBook\n            return updatedBook\n        }\n        return null\n    }\n\n    @DeleteMapping(\"/{id}\")\n    fun deleteBook(@PathVariable id: Long): Boolean {\n        return books.removeIf { it.id == id }\n    }\n}\n```\n#### 5. Run the Application\n\nRun your Spring Boot application. If you're using IntelliJ IDEA, you can run the DemoApplication class.\n\n#### 6. Test the APIs\n\nYou can test your API using tools like Insomnia, Postman, or a web browser.\n\n- To get all books: `GET http://localhost:8080/api/books`\n- To add a book: `POST http://localhost:8080/api/books` with a JSON payload.\n- To update a book: `PUT http://localhost:8080/api/books/{id}` with a JSON payload.\n- To delete a book: `DELETE http://localhost:8080/api/books/{id}`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarx-wrld%2Fkotlinwithspringboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarx-wrld%2Fkotlinwithspringboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarx-wrld%2Fkotlinwithspringboot/lists"}