DEV Community

loizenai
loizenai

Posted on

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

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-boot-restapis-download-csv-file-example-apache-commons-csv-mysql

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

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:

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:

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>      
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>   
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-csv</artifactId>
    <version>1.5</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

Customer Model

  • Customer.kt ->

More at:

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-boot-restapis-download-csv-file-example-apache-commons-csv-mysql

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

Top comments (0)