Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quarkus for Spring developers: Getting started

September 20, 2021
Eric Deandrea
Related topics:
JavaKubernetesMicroservicesQuarkusSpring Boot
Related products:
Red Hat build of Quarkus

Share:

    Want to learn more about developing applications with Quarkus? Download our free e-book Quarkus for Spring Developers, which helps Java developers familiar with Spring make a quick and easy transition.

    The tools available in the Spring ecosystem make it easy to get started with building applications. However, the same is true for Quarkus, which has many additional features and capabilities aimed at improving the developer experience. A Spring developer can quickly get started working with a Quarkus project and immediately become more productive, as we'll see in this article. Plug-ins and tooling are available for most major IDEs, including VSCode, IntelliJ, and Eclipse.

    Creating a new project

    A Spring developer’s starting point is the Spring Initializr, which can be used directly from the website, as shown in Figure 1, or via plug-ins for most major IDEs.

    Figure 1 - Spring Initializr
    Figure 1: Spring Initializr.

    Quarkus projects start at Code Quarkus. The project generator can be used directly from the website, as shown in Figure 2, or via plug-ins for all of the IDEs mentioned previously.

    Figure 2 - Code Quarkus
    Figure 2: Code Quarkus.

    Using Code Quarkus, you can describe the project's Maven coordinates, build tool of choice, and the technologies needed by the application, known as Quarkus extensions. Highlighted in Figure 2 are the following:

    1. An extension that provides example code.
    2. Whether or not to include an extension's example code during project generation.
    3. Extensions newer to the community are marked PREVIEW. Such an extension may have API or configuration changes as it matures.
    4. Extensions brand new to the community are marked EXPERIMENTAL. Such an extension provides no guarantees of stability or long-term presence until it matures.
    5. Additional details about each extension, including a link to the guide for the extension and how to add the extension to an existing project.

    Project structure

    A Quarkus project’s structure is similar to a Spring Boot project’s structure. Table 1 details some files and directories of a Quarkus project.

    Table 1: Quarkus project structure.
    File / Directory Description
    README.md Contains instructions on building and running the application, including native image.

    pom.xml
    build.gradle

    Project build file.
    src/main/docker Sample Dockerfiles for use in different modes (JVM, native image).
    src/main/java All application source code.
    src/main/resources All application resources.

    src/main/resources/application.properties
    src/main/resources/application.yml
    src/main/resources/application.yaml

    All application configurations, unified in a single file.
    src/main/resources/META-INF/resources All application static content.
    src/test/java All application test code.

    Quarkus Dev Mode and live coding

    The Quarkus developer experience begins with a simple command: ./mvnw quarkus:dev (for Maven) or ./gradlew quarkusDev (for Gradle). This command will start Quarkus’s Dev Mode, which automatically detects changes made to a project. Changes could involve source files, configuration, static resources, or classpath dependencies. Quarkus transparently recompiles and redeploys detected changes typically in under a second. This feature allows developers to continuously write code and have the underlying platform seamlessly incorporate changes into the running application.

    In some instances, it may not be possible or feasible to provision necessary dependent services onto a local developer workstation. In these instances, the only option is to continually deploy the application into an environment where these services are available. Without Quarkus, a developer needs to rebuild and redeploy the application each time a change is made. In some instances, this redeployment could take a minute or more. Running ./mvnw quarkus:remote-dev (for Maven) or ./gradlew quarkusRemoteDev (for Gradle) will enable Remote Dev Mode, extending automatic reloading to applications deployed on remote hosts, typically redeploying and reloading within a second or two. This capability greatly reduces the developer’s inner feedback loop.

    Dev Services

    Does your application require a running database? Apache Kafka broker? Redis server? AMQP broker? OpenID Connect Authorization Server? API/Schema registry? When running Quarkus Dev Mode, Quarkus Dev Services automatically bootstraps infrastructure needed by an application based on what extensions are present. For example, Quarkus will automatically bootstrap a database container image and set all the required configuration properties if it sees a database extension present and no configuration has been supplied.

    Quarkus Dev Services speed up inner-loop development by providing necessary infrastructure without you having to think about it. New services are continually added to the platform.

    Continuous testing

    Test-driven development is an adopted practice within many development teams. Continuous testing support in Quarkus enables developers to take advantage of this practice. When running Quarkus Dev Mode, you can enable continuous testing with the press of a key, enabling Quarkus to automatically rerun tests affected by a code change in the background.

    Quarkus understands which tests are affected by classes and methods within the application. As you make code changes, you get immediate feedback if the change passes your existing test suite. This capability is integrated directly into Quarkus—no IDE or special tooling is required.

    Natively native

    ./mvnw package -Pnative (for Maven) or ./gradlew build -Dquarkus.package.type=native (for Gradle) is all that’s needed to build a Quarkus application into a native image. All the heavy lifting and integration to consume GraalVM is done for you by the Quarkus build tools. Developers or CI/CD systems simply need to run a build, just like any other Java build, to produce a native executable. Tests can even be run against the built artifact.

    Quarkus’s design accounted for native compilation from the onset. A Quarkus native executable starts much faster and uses far less memory than a traditional JVM. Similar native image capabilities in Spring are still considered experimental or beta.

    Kubernetes native

    Quarkus was designed with low memory optimization and fast startup times in mind, making it a perfect fit for containers and container orchestration platforms such as Kubernetes. Quarkus performs as much processing as possible at build time, reducing the size and footprint of the application running on the JVM. Many more Quarkus applications can be deployed than other Java or Spring applications.

    Simply adding the Quarkus Kubernetes extension (or the Quarkus OpenShift extension, if using Red Hat OpenShift Container Platform) will automatically generate Kubernetes (or OpenShift) resources based on the project. Want to run your application serverless? The Kubernetes (or OpenShift) extension can also generate Knative resources, enabling you to deploy your application in a serverless fashion, whether it's on the JVM or a native image. Combined with previously-mentioned capabilities like Remote Dev Mode or continuous testing, Quarkus gives you a Kubernetes-native development experience.

    Where to learn more

    There are many free resources available for learning about and getting started with Quarkus. Why wait for the future? Since its inception in 2019 and continuing today and into the future, Quarkus has provided a familiar and innovative framework for Java developers, supporting capabilities developers need and want today.

    Check out these other available resources:

    • Read Quarkus for Spring Developers to learn about what challenges led to Quarkus and see side-by-side examples of familiar Spring concepts, constructs, and conventions.
    • Learn why you should choose Quarkus over Spring for microservices development.
    • Explore Quarkus quick starts in the Developer Sandbox for Red Hat OpenShift, which offers a free and ready-made environment for experimenting with containerized applications.
    • Try free 15-minute interactive learning scenarios.
    • Get started with Quarkus on your own.
    • Learn about Quarkus's Spring compatibility features.
      • In some instances, there might not be any code changes needed to run a Spring application on Quarkus.
      • Get hands-on converting a Spring Boot application to Quarkus with little-to-no code changes.
    • Attend a Quarkus World Tour event when it comes to a city near you. You can even request a private stop.
    Last updated: September 20, 2023

    Related Posts

    • Why should I choose Quarkus over Spring for my microservices?

    • Spring Boot on Quarkus: Magic or madness?

    • Learn Quarkus faster in the Developer Sandbox for Red Hat OpenShift

    • Enhancing the development loop with Quarkus remote development

    Recent Posts

    • How to run AI models in cloud development environments

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    • How to encrypt RHEL images for Azure confidential VMs

    • How to manage RHEL virtual machines with Podman Desktop

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue