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
<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>JPA CRUD
public interface DemoUserDao extends CrudRepository<DemoUser, Long> {
}Migration to Quarkus
quarkus-bom manages all Quarkus plugin Maven version information; after adding it, individual dependencies no longer need version definitions.
<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>Migrate spring-web and spring-data-jpa to the Quarkus stack.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web</artifactId>
</dependency>Configuration file adjustments (still in application.yml)
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=TRUEMain method adjustment to implement QuarkusApplication and keep the service running with Quarkus.waitForExit().
@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;
}
}Running the Application
The main method starts the application and prints the Quarkus banner.
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | /_ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/,< /_/_ /\
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
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]It is important that the installed features are displayed.
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]Extension: Actuator Monitoring Migration
Add the following dependency
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>Specify the health endpoint path
quarkus.smallrye-health.root-path=/actuator/healthTest the health endpoint
curl http://localhost:8080/actuator/health
{
"status": "UP",
"checks": [
{
"name": "Database connections health check",
"status": "UP"
}
]
}Extension: Flyway Migration
Add the Quarkus Flyway plugin
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
</dependency>Set the plugin to migrate at start
quarkus.flyway.migrate-at-start=trueSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
