How to Migrate a Spring Boot JPA App to Quarkus for Faster Startup
This guide demonstrates step‑by‑step how to transform a Spring Boot application that uses JPA for CRUD operations into a Quarkus‑based microservice, covering Maven dependencies, configuration changes, main class adaptation, and optional extensions such as actuator health checks and Flyway migrations.
Quarkus is a hot Java application framework positioned as a lightweight microservice framework, offering excellent container integration, faster startup, lower memory consumption, and shorter response times compared to traditional frameworks like Spring Boot.
This article demonstrates how to migrate a Spring Boot application to Quarkus.
Spring Boot Sample Application
Using JPA to perform CRUD operations, the basic code is as follows:
Maven dependencies
<code><dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</code>JPA CRUD
<code>public interface DemoUserDao extends CrudRepository<DemoUser, Long> {
}
</code>Migration to Quarkus
quarkus-bom manages all Quarkus plugin Maven version information; after adding it, individual dependencies no longer need version definitions.
<code><dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>1.10.5.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</code>Migrate spring-web and spring-data-jpa to the Quarkus stack.
<code><dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web</artifactId>
</dependency>
</code>Configuration file adjustments (still in application.yml)
<code>quarkus.datasource.db-kind=mysql
quarkus.datasource.jdbc.driver=com.mysql.cj.jdbc.Driver
quarkus.datasource.username=root
quarkus.datasource.password=root
quarkus.datasource.jdbc.url=jdbc:mysql://localhost:3306/pig_demo?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE
</code>Main method adjustment to implement
QuarkusApplicationand keep the service running with
Quarkus.waitForExit().
<code>@QuarkusMain
public class SimpleApplication implements QuarkusApplication {
public static void main(String[] args) {
Quarkus.run(SimpleApplication.class, args);
}
@Override
public int run(String... args) {
Quarkus.waitForExit();
return 0;
}
}
</code>Running the Application
The main method starts the application and prints the Quarkus banner.
<code>__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | /_ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/,< /_/_ /\
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-01-12 22:31:46,341 INFO [io.qua.arc.pro.BeanProcessor] (build-21) Found unrecommended usage of private members (use package-private instead) in application beans:
- @Inject field com.example.simple.controller.DemoController#userDao
2021-01-12 22:31:48,702 INFO [io.quarkus] (Quarkus Main Thread) Quarkus 1.10.5.Final on JVM started in 4.613s. Listening on: http://localhost:8080
2021-01-12 22:31:48,703 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-01-12 22:31:48,703 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, mutiny, narayana-jta, resteasy, resteasy-jackson, smallrye-context-propagation, spring-data-jpa, spring-di, spring-web]
</code>It is important that the installed features are displayed.
<code>Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, mutiny, narayana-jta, resteasy, resteasy-jackson, smallrye-context-propagation, spring-data-jpa, spring-di, spring-web]
</code>Extension: Actuator Monitoring Migration
Add the following dependency
<code><dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
</code>Specify the health endpoint path
<code>quarkus.smallrye-health.root-path=/actuator/health
</code>Test the health endpoint
<code>curl http://localhost:8080/actuator/health
{
"status": "UP",
"checks": [
{
"name": "Database connections health check",
"status": "UP"
}
]
}
</code>Extension: Flyway Migration
Add the Quarkus Flyway plugin
<code><dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
</dependency>
</code>Set the plugin to migrate at start
<code>quarkus.flyway.migrate-at-start=true
</code>Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.