Kotlin Spring Boot RestAPIs – Download CSV File example – Apache Commons CSV + MySQL

kotlin-springboot-restapi-download-csv-file-spring-jpa-mysql-apachec-commons-csv-feature-image

In the tutorial, we show you how to create a Kotlin SpringBoot RestAPIs application that uses Spring JPA to get data from MySQL records and uses Apache Commons CSV library to write data to a CSV file.

Related posts:
Kotlin – How to read/write CSV file with Apache Commons CSV
Kotlin Spring JPA + Postgresql | Spring Boot Example
Kotlin SpringBoot Upload/Download File – MultipartFile + Thymeleaf + Bootstrap 4 example

Technologies

– Kotlin Spring Boot – 2.0.6.RELEASE
– Spring JPA
– MySQL
– Apache Commons CSV

Practice

Project Structure ->

kotlin-springboot-restapi-download-csv-file-spring-jpa-mysql-project-structure

Create Kotlin SpringBoot project

Use SpringToolSuite to create a Kotlin SpringBoot project with below dependencies:

Customer Model

Customer.kt ->

JPA Customer Repository

CustomerRepository.kt ->

Implement CSV Generator

CSVGenerator.kt ->

Implement RestAPI Controller

CustomerRestAPIs ->

Implement Download View

– Create a view controller ViewController.kt ->

– Create .html view home.html ->

Initial Customers

– In the main class, we use CommandLineRunner to initial data ->

Database Configuration

application.properties ->

Run & Check Results

– Run the SpringBoot project,

-> MySQL records:

kotlin-springboot-restapi-download-csv-file-spring-jpa-mysql-schema-records

-> Download CSV File:

kotlin-springboot-restapi-download-csv-file-spring-jpa-mysql-apache-commons-csv-view

kotlin-springboot-restapi-download-csv-file-spring-jpa-mysql-csv-content

SourceCode

KotlinSpringJpaCsv

By grokonez | October 26, 2018.



Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*