This exercise demonstrates how Spring and Spring Boot developers can use well-known Spring annotations for Spring Data, Web, and Dependency Injection when building Quarkus applications. Spring developers can quickly become productive with Quarkus using existing knowledge and familiarity with these APIs.

You'll build a relatively simple application that uses Spring Data to integrate (via JPA) with an underlying database, inject beans using Spring DI and expose them as RESTful endpoints via Spring Rest.

Creating a Basic Project

Let's create the basic Quarkus Hello World application and include the necessary spring extensions. This command will create the project:

mvn io.quarkus:quarkus-maven-plugin:2.16.3.Final:create \
  -DprojectGroupId=org.acme \
  -DprojectArtifactId=fruit-taster \
  -Dextensions="spring-data-jpa,spring-web,spring-di,jdbc-postgres,jdbc-h2" \
  -DclassName="org.acme.quickstart.GreetingResource" \

This will use the Quarkus Maven Plugin and generate a basic Maven project for you in the fruit-taster subdirectory and include the following extensions to enable Spring annotations and APIs:

  • spring-data-jpa - Adds Spring Data annotations, such as @CrudRepository allowing integration with database-backed JPA repositories
  • spring-web - Adds Spring Web annotations, such as @RestController, @RequestMapping, @PathVariable, @GetMapping, etc.
  • spring-di - Adds Spring DI annotations, such as @Autowired, @Configuration, @Component, etc.
  • jdbc-postgres - Driver for PostgreSQL database. Keep in mind that this is the JDBC variant. Reactive programmers may be interested in the Reactive Postgres Client.
  • jdbc-h2 - Alsos the use of the h2 database for local development

Starting the Application

First, change to the directory in which the project was created:
cd fruit-taster
Start the application in development mode:
mvn compile quarkus:dev
Note: The first time you build the app, new dependencies may be downloaded via maven. This should only happen once, after that things will go faster.
Open a new terminal and test that the app is running by accessing the simple hello endpoint:
curl localhost:8080/hello
You should receive the response:
Hello Spring

Next Steps

This application currently does not use any of the Spring annotations. In the next few steps, we'll add those. We won't need to restart the running application because of Quarkus' ability to recompile code on the fly.

Daniel Oh
Daniel Oh
Senior Principal Developer Advocate
Daniel Oh is a Senior Principal Developer Advocate at Red Hat. He works to evangelize building cloud-native microservices and serverless functions with cloud-native runtimes to developers. He also continues to contribute to various open-source cloud projects and ecosystems as a Cloud Native Computing Foundation (CNCF) ambassador for accelerating DevOps adoption in enterprises. Daniel also speaks at technical seminars, workshops, and meetups to elaborate on new emerging technologies for enterprise developers, SREs, platform engineers, and DevOps teams.