Quarkus Dev Services: Zero-Config Development for Java Developers
Streamline your workflow with automated database provisioning, live reloading, and seamless integration—no manual setup required.
As Java developers, we want a fast, iterative development process. We want to write code, see changes immediately, and build applications efficiently. However, a significant portion of development time is spent waiting. Waiting for databases to start, message brokers to initialize, and services to become ready before even running a single line of code. The inner loop, writing, testing, and debugging, can slow down due to configuration overhead.
Quarkus Dev Services simplifies this by automatically provisioning and managing external dependencies during development and testing. Whether you need a database, a message broker, an OpenID Connect provider, or other services, Quarkus Dev Services handles the setup, so you can focus on writing application logic.
This article walks through a practical example to demonstrate how Dev Services streamlines development. We'll build a simple RESTful application that interacts with a database and see how Quarkus automates the setup.
The Traditional Setup: Manual Configuration Overhead
Imagine you're building a simple service to manage a list of books. Without Quarkus Dev Services, your workflow might look like this:
Database Setup: Download and install PostgreSQL, MySQL, or MariaDB. Configure users, passwords, and database schemas manually or through Docker Compose.
Connection Configuration: Define database connection properties (URL, username, password) in
application.properties
.Initialization Scripts: Write SQL scripts to create tables and populate them with data.
Trial and Error: Start the application and troubleshoot connection issues if they arise.
This process adds overhead, introduces room for error, and shifts focus away from coding.
Quarkus Dev Services: Automated Setup
Quarkus Dev Services follows "convention over configuration" principles to simplify development:
Add a Dependency – Specify the required database or service by adding a Quarkus extension.
Write Code – Use JDBC, Panache, or other APIs without manually configuring connection details.
Run the Application – Start in development mode (
./mvnw quarkus:dev
). Quarkus detects dependencies, provisions the necessary services using Testcontainers, and manages configuration.Iterate – Make code changes while Quarkus automatically manages service lifecycles.
No manual setup or configuration files are required for basic development.
Building a Book Service with Quarkus Dev Services
Prerequisites
Java 11+
Maven
Docker (required by Testcontainers)
An IDE (IntelliJ IDEA, VS Code, Eclipse, etc.)
1. Generate a Quarkus Project
Create a new Quarkus project using the Quarkus CLI or Maven:
mvn io.quarkus:quarkus-maven-plugin:3.19.4:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=book-service \
-DclassName="org.acme.BookResource" \
-Dextensions="resteasy-reactive-jackson,jdbc-postgresql,hibernate-orm-panache"
cd book-service
This command:
Creates a new Quarkus project.
Sets the group ID (
org.acme
) and artifact ID (book-service
).Generates a REST resource (
BookResource
).Includes dependencies for REST (RESTEasy Reactive), PostgreSQL (JDBC driver), and Hibernate ORM with Panache.
2. Define the Book
Entity
Create src/main/java/org/acme/Book.java
:
package org.acme;
import io.quarkus.hibernate.orm.panache.PanacheEntity;
import jakarta.persistence.Entity;
@Entity
public class Book extends PanacheEntity {
public String title;
public String author;
public String genre;
public Book() {}
public Book(String title, String author, String genre) {
this.title = title;
this.author = author;
this.genre = genre;
}
}
This defines a Book
entity with title
, author
, and genre
fields. Panache simplifies entity management.
3. Implement the REST Resource
Replace src/main/java/org/acme/BookResource.java
with:
package org.acme;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.util.List;
@Path("/books")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class BookResource {
@GET
public List<Book> list() {
return Book.listAll();
}
@POST
@Transactional
public Response create(Book book) {
book.persist();
return Response.status(Response.Status.CREATED).entity(book).build();
}
@GET
@Path("/{id}")
public Book get(@PathParam("id") Long id) {
return Book.findById(id);
}
@DELETE
@Path("/{id}")
@Transactional
public Response delete(@PathParam("id") Long id) {
Book entity = Book.findById(id);
if (entity == null) {
throw new WebApplicationException("Book with id " + id + " not found.", 404);
}
entity.delete();
return Response.status(Response.Status.NO_CONTENT).build();
}
@PUT
@Path("/{id}")
@Transactional
public Book update(@PathParam("id") Long id, Book updatedBook) {
Book entity = Book.findById(id);
if (entity == null) {
throw new WebApplicationException("Book with id " + id + " not found.", 404);
}
entity.title = updatedBook.title;
entity.author = updatedBook.author;
entity.genre = updatedBook.genre;
return entity;
}
}
This REST resource provides basic CRUD operations for books.
4. Run the Application
Start in development mode:
./mvnw quarkus:dev
Quarkus will:
Detect the PostgreSQL dependency.
Start a PostgreSQL container with Testcontainers.
Configure the application to connect automatically.
Generate the
book
table (via Hibernate ORM).Enable hot-reloading for code changes.
Provide a Dev UI (
http://localhost:8080/q/dev-ui
).
5. Test the API
Use curl
or Postman:
Create a Book
curl -X POST -H "Content-Type: application/json" \
-d '{"title":"The Hitchhiker''s Guide to the Galaxy", "author":"Douglas Adams", "genre":"Science Fiction"}' \
http://localhost:8080/books
List All Books
curl http://localhost:8080/books
Get a Book by ID
curl http://localhost:8080/books/1
Update a Book
curl -X PUT -H "Content-Type: application/json" \
-d '{"title":"The Restaurant at the End of the Universe", "author":"Douglas Adams", "genre":"Science Fiction"}' \
http://localhost:8080/books/1
Delete a Book
curl -X DELETE http://localhost:8080/books/1
No manual database setup was required: Quarkus Dev Services handled it.
Beyond Databases: Other Dev Services
Quarkus Dev Services can also provision:
Kafka / AMQP – Add
quarkus-smallrye-reactive-messaging-kafka
to start a Kafka broker.Mail Server – Use
quarkus-mailer
for a mock SMTP server (MailHog).OpenID Connect – Include
quarkus-oidc
to start a Keycloak instance for authentication testing.MongoDB / Redis – Use
quarkus-mongodb-client
orquarkus-redis-client
for automatic provisioning.And many many many more.
For more details, see Quarkus Dev Services.
Summary
Quarkus Dev Services reduces setup time, letting you focus on development. It automatically provisions dependencies, allowing for faster iteration and testing. If you're using Quarkus, give Dev Services a try—it makes development more efficient.