SpringBoot Upload Multiple Files to MySQL Example – Thymeleaf + Spring JPA Audit


In the tutorial, we show you how to build a SpringBoot RestAPIs to upload multiple files to MySQL database with Thymeleaf frontend, and Spring JPA Audit feature.

Related posts:
Spring Data JPA Auditing Example – SpringBoot RestAPIs + MySQL
SpringBoot RestAPIs + Thymeleaf – Upload/Download Multiple Files to FileSystem Example


– Java 8
– Maven 3.6.1
– SpringBoot
– Thymeleaf
– Bootstrap 4


– We create a SpringBoot project as below:


– Upload Multiple Files ->



– Download Form ->



SpringBoot Backend Implementation
Create SpringBoot project

We use SpringToolSuite to create a SpringBoot project with below dependencies:

jackson-datatype-jsr310 is used to support Java 8 Date/Time for JPA Audit feature.

Implement DateAudit

– Configure JPA Auditing:

– Implement DateAudit ->

@EntityListeners annotation is used to specify callback listener classes. We use the JPA entity listener class of Spring Data AuditingEntityListener.
@MappedSuperClass annotation is used to move the properties to a base class DateAudit which would be extended by all your audited entities.

Build File Model

FileModel.java ->

Define File Repository

FileRepository.java ->

Upload Multiple Files Controller

UploadFileController.java ->

– We can limit the size of uploaded file by using below configuration in application.properties ->

Download Files Controller

– Firstly, create FileInfo.java ->

– Implement download controller DownloadFileController.java ->

Application Configuration

application.properties ->

Main Class Implementation

– Set the default timezone for our application to UTC.

Thymeleaf Frontend Implementation
Upload Form

uploadform.html ->

Download Form

listfiles.html ->

Run & Check Results

Run the SpringBoot project,

– Upload Multiples files:



-> Results:



– Change text in grokonez-about-us.txt then upload 3 files again, results ->


– Download files:


-> results:




By grokonez | November 7, 2018.

Related Posts

1 thought on “SpringBoot Upload Multiple Files to MySQL Example – Thymeleaf + Spring JPA Audit”

  1. hi,

    thanks for sharing the process on upload and download file to mysql.
    this works like a charm when i run it as a stand alone application, but when i apply the same within my project i get a sql error stating “Unknown column ‘filemodel0_.createdAt’ in ‘field list'”

    request you to kindly help me on the same and have been trying to figure this out where am going wrong for days now

Got Something To Say:

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