# End-to-End Guide

Source: https://guicedee.com/guides/end-to-end

# End-to-End Guide

Build production-ready reactive microservices and  moduliths  from scratch. This guide covers REST endpoints with security, CORS, outbound REST clients, database persistence with  Hibernate Reactive ,  MicroProfile Config , health checks, cloud-aware JSON logging, verticle isolation, and JLink deployment into distroless Docker containers.

Real-world

Production-ready

Full stack

JLink + Docker

Project setup

## BOM + only what you need

Five dependencies for full-featured microservices and moduliths. No version numbers required.

Import the GuicedEE BOM and add the modules you need. Each module is self-contained with its own JPMS descriptor — you build up, never exclude down.

```xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.guicedee</groupId>
            <artifactId>guicedee-bom</artifactId>
            <version>2.6.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.guicedee</groupId>
        <artifactId>rest</artifactId>
    </dependency>
    <dependency>
        <groupId>com.guicedee</groupId>
        <artifactId>health</artifactId>
    </dependency>
    <dependency>
        <groupId>com.guicedee.microprofile</groupId>
        <artifactId>config</artifactId>
    </dependency>
    <dependency>
        <groupId>com.guicedee</groupId>
        <artifactId>rest-client</artifactId>
    </dependency>
    <dependency>
        <groupId>com.guicedee</groupId>
        <artifactId>persistence</artifactId>
    </dependency>
</dependencies>
```

```groovy
dependencies {
    implementation platform('com.guicedee:guicedee-bom:2.6.0')

    implementation 'com.guicedee:rest'
    implementation 'com.guicedee:health'
    implementation 'com.guicedee.microprofile:config'
    implementation 'com.guicedee:rest-client'
    implementation 'com.guicedee:persistence'
}
```

Module descriptor

## JPMS Level 3 — explicit, safe, JLink-ready

Every dependency is declared. No automatic modules, no classpath surprises.

```java
module my.service {
    requires transitive com.guicedee.guicedinjection;
    opens com.example.myservice to com.google.guice;

    provides com.guicedee.client.services.lifecycle.IGuiceModule
        with com.example.myservice.AppModule;
}
```

Explicit  requires  for every module you use.  opens  for private field and AOP injection.  provides  to register your Guice module via  ServiceLoader . This is JPMS Level 3 — JLink resolves the entire graph.

Guice module & bootstrap

## Bindings + one-line startup

GuiceApplication.run(Runnable) runs preparation, injects, starts servers, registers routes, and waits for asynchronous startup. Failed startup triggers cleanup and an unsuccessful process exit. Use it in your application's main entry point.

```java
public class AppModule extends AbstractModule
        implements IGuiceModule<AppModule> {
    @Override
    protected void configure() {
        bind(OrderService.class).to(DefaultOrderService.class);
        bind(UserService.class).to(DefaultUserService.class);
    }
}
```

```java
import com.guicedee.client.IGuiceContext;
import com.guicedee.guicedinjection.GuiceApplication;

public class Boot {
    public static void main(String[] args) {
        GuiceApplication.run(() -> {
            IGuiceContext.registerModule("my.service");
        });
    }
}
```

REST endpoints

## Jakarta REST on Vert.x 5

Standard @Path annotations, Guice injection, reactive returns — all auto-discovered. See the REST module page for full details.

```java
@Path("/api/orders")
@Produces(MediaType.APPLICATION_JSON)
public class OrderResource {

    @Inject private OrderService orders;

    @GET
    public Uni<List<Order>> list(
            @QueryParam("status") String status,
            @QueryParam("page") @DefaultValue("1") int page) {
        return orders.findByStatus(status, page);
    }

    @POST @Consumes(MediaType.APPLICATION_JSON)
    @RolesAllowed("order:write")
    public Uni<Response> create(OrderRequest request) {
        return orders.create(request)
            .onItem().transform(order ->
                Response.status(201).entity(order).build());
    }

    @GET @Path("/{id}")
    public Uni<Order> get(@PathParam("id") String id) {
        return orders.findById(id);
    }

    @DELETE @Path("/{id}")
    @RolesAllowed("admin")
    public Uni<Void> delete(@PathParam("id") String id) {
        return orders.delete(id);
    }
}
```

### Reactive returns

Uni<T> ,  Future<T> , or plain values. Non-blocking on the event loop.

### Guice-injected

@Inject  works in every resource. Full DI lifecycle.

### Auto-discovered

ClassGraph  finds  @Path  classes. No registration.

### Jackson serialization

Request/response bodies (de)serialized automatically.

Security

## @RolesAllowed + pluggable Vert.x auth

Jakarta annotations with Vert.x handlers — no config files. See the security section in capabilities for more.

Apply standard Jakarta security annotations. Then plug in your  Vert.x  authentication handler — JWT, OAuth2, Basic, or custom. No security.xml, no realm config files.

```java
public class SecuritySetup implements IGuicePostStartup<SecuritySetup> {
    @Override
    public List<Uni<Boolean>> postLoad() {
        var jwtAuth = JWTAuth.create(vertx, new JWTAuthOptions()
            .addPubSecKey(new PubSecKeyOptions()
                .setAlgorithm("RS256")
                .setBuffer(publicKey)));

        SecurityHandler.setDefaultAuthenticationHandler(
            JWTAuthHandler.create(jwtAuth));

        return List.of(Uni.createFrom().item(true));
    }
}
```

### @RolesAllowed

Class or method level. Checked against the authenticated  Vert.x User .

### @PermitAll / @DenyAll

Method-level overrides class-level. Standard Jakarta annotations.

### HTTPS / TLS

HTTPS_ENABLED=true , auto-detected JKS or PKCS#12 keystores.

### Call-scoped isolation

Each request gets its own  Guice CallScope  with user context.

CORS

## Annotation or env-var driven

Apply @Cors at class/method level. Override any value with REST_CORS_* env vars at deploy time.

```java
@Path("/api/data")
@Cors(allowedOrigins = {"https://app.example.com"},
      allowedMethods = {"GET", "POST", "PUT"},
      allowCredentials = true,
      maxAgeSeconds = 3600)
public class DataResource { /* ... */ }
```

```java
REST_CORS_ENABLED=true
REST_CORS_ALLOWED_ORIGINS=https://app.example.com
REST_CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE
REST_CORS_ALLOW_CREDENTIALS=true
```

REST client

## Typed, reactive, annotation-driven outbound calls

See the REST client module page for full configuration, error handling, and SPI hooks.

```java
public class PaymentService {

    @Endpoint(url = "https://api.stripe.com/v1/charges",
              method = "POST",
              security = @EndpointSecurity(
                  value = SecurityType.Bearer,
                  token = "${STRIPE_SECRET_KEY}"),
              options = @EndpointOptions(
                  connectTimeout = 5000, readTimeout = 10000))
    @Named("stripe-charge")
    private RestClient<ChargeRequest, ChargeResponse> chargeClient;

    public Uni<ChargeResponse> charge(ChargeRequest req) {
        return chargeClient.send(req);
    }
}

// Inject by name anywhere else — no @Endpoint needed:
@Inject @Named("stripe-charge")
private RestClient<ChargeRequest, ChargeResponse> client;
```

### Bearer / JWT

Token from ${ENV_VAR}

### Basic auth

Username + password from env vars

### API Key

Custom header with key

### Path params

{userId} placeholders, URL-encoded

Health checks

## MicroProfile Health — Kubernetes-ready

Auto-discovered, auto-registered. Paths configurable via env vars.

```java
@Liveness
public class AppHealth implements HealthCheck {
    @Inject private OrderService orders;

    @Override
    public HealthCheckResponse call() {
        return HealthCheckResponse
            .named("order-service")
            .status(orders != null)
            .withData("version", "1.0.0")
            .build();
    }
}
```

### /health

All checks aggregated

### /health/live

@Liveness — is it alive?

### /health/ready

@Readiness — accepting traffic?

### /health/started

@Startup — finished init?

Configuration

## MicroProfile Config — no files required

Typed @ConfigProperty injection. Override everything via env vars.

```java
public class DefaultOrderService implements OrderService {

    @ConfigProperty(name = "order.max-items",
                    defaultValue = "100")
    int maxItems;

    @ConfigProperty(name = "order.default-currency",
                    defaultValue = "USD")
    String currency;
}
```

Priority: 1) Environment variables  2) System properties  3) microprofile-config.properties. Override at deploy time: ORDER_MAX_ITEMS=500

Persistence

## Hibernate Reactive 4.5 and ORM 7.4 with Mutiny

Fully async database access. See the persistence module page for entities, transactions, and multi-db setup.

Hibernate Reactive 4.5 and ORM 7.4  with  Mutiny . Non-blocking database access on the  Vert.x  event loop. Multi-database support with env-var driven connection details.

```java
public class MyDatabaseModule
        extends DatabaseModule<MyDatabaseModule> {
    @Override
    protected String getPersistenceUnitName() {
        return "mydb";
    }

    @Override
    protected ConnectionBaseInfo getConnectionBaseInfo(
            PersistenceUnitDescriptor unit, Properties properties) {
        return ConnectionBaseInfoFactory.createConnectionBaseInfo("postgresql");
    }
}
```

```java
@Inject
private Mutiny.SessionFactory sessionFactory;

public Uni<Order> findById(String id) {
    return sessionFactory.withSession(session ->
        session.find(Order.class, id));
}

public Uni<List<Order>> findByStatus(String status, int page) {
    return sessionFactory.withSession(session ->
        session.createQuery(
            "FROM Order WHERE status = :status", Order.class)
            .setParameter("status", status)
            .setFirstResult((page - 1) * 20)
            .setMaxResults(20)
            .getResultList());
}

public Uni<Order> save(Order order) {
    return sessionFactory.withTransaction(session ->
        session.persist(order).replaceWith(order));
}
```

### Hibernate Reactive 4.5 and ORM 7.4

Fully async with  Mutiny   Uni / Multi .

### DatabaseModule required

GuicedEE creates the persistence unit from supplied properties, merged with  persistence.xml  if provided.

### Multi-database

Multiple  DatabaseModule  subclasses with  @Named  qualifiers.

### ConnectionBaseInfoFactory

Use  ConnectionBaseInfoFactory.createConnectionBaseInfo("postgresql")  — supports postgresql, mysql, sqlserver, oracle, db2.

### Vert.x pool

Pre-initialized connection pools on the event loop.

Verticle isolation

## @Verticle packages with dedicated worker pools

Isolate API groups with separate threading, pool sizes, and sub-routers.

```java
@Verticle(value = "payments-pool",
          workerPoolSize = 16,
          maxWorkerExecuteTime = 30,
          maxWorkerExecuteTimeUnit = TimeUnit.SECONDS,
          capabilities = {Capabilities.Rest,
                          Capabilities.Persistence})
package com.example.payments;
```

```java
public class MyServerOptions
        implements VertxHttpServerOptionsConfigurator {
    @Override
    public HttpServerOptions builder(HttpServerOptions opts) {
        opts.setIdleTimeout(60);
        return opts;
    }
}
```

### VertxHttpServerOptionsConfigurator

Before server creation — ports, TLS, buffers.

### VertxHttpServerConfigurator

After creation — connection handlers, WebSocket upgrade.

### VertxRouterConfigurator

Add routes and middleware.  sortOrder()  for execution order.

Cloud-aware logging

## CLOUD=true — that's it

Colorized locally, JSON in the cloud. Standard log4j2.xml and Log4j2 APIs still work — this is a programmatic alternative, not a replacement.

```java
# Local: colorized, human-readable
[2026-03-06 14:23:01] [c.e.OrderService] [INFO ] - Order 42 placed

# Cloud: CLOUD=true → structured JSON
{"level":"INFO","loggerName":"c.e.OrderService",
 "message":"Order 42 placed","traceId":"abc123"}
```

```java
CLOUD=true              # JSON logging
LOG_LEVEL=INFO           # Root log level
DEBUG=true               # Quick toggle
```

### No log4j2.xml required

Programmatic config in the static initializer. Existing log4j2.xml files are still honoured if present.

### Stdout/Stderr split

INFO→stdout, ERROR→stderr. No sidecar.

### @InjectLogger

Named loggers via injection. No static fields.

### Runtime switching

Switch to JSON at runtime. No restart.

JLink deployment

## Custom runtimes in minimal Docker containers

JPMS Level 3 makes this possible. Build a custom JRE and ship ~40 MB images.

```xml
<!-- pom.xml — moditect-maven-plugin creates the JLink image -->
<plugin>
    <groupId>org.moditect</groupId>
    <artifactId>moditect-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-module-infos</id>
            <phase>none</phase>
            <configuration combine.self="override">
                <skip>true</skip>
            </configuration>
        </execution>
        <execution>
            <id>create-runtime-image</id>
            <phase>package</phase>
            <goals>
                <goal>create-runtime-image</goal>
            </goals>
            <configuration>
                <modulePath>
                    <path>${project.build.directory}/libs</path>
                    <path>${project.build.directory}/${project.build.finalName}.jar</path>
                </modulePath>
                <modules>
                    <module>my.service</module>
                </modules>
                <jarInclusionPolicy>NONE</jarInclusionPolicy>
                <launcher>
                    <name>myservice</name>
                    <module>my.service/com.example.Main</module>
                </launcher>
                <noHeaderFiles>true</noHeaderFiles>
                <noManPages>true</noManPages>
                <stripDebug>true</stripDebug>
                <outputDirectory>
                    ${project.build.directory}/jlink-image
                </outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

# Dockerfile
FROM gcr.io/distroless/base-nossl-debian12
COPY target/jlink-image /app/jrt
ENV CLOUD=true
ENTRYPOINT ["/app/jrt/bin/myservice"]

# Build and deploy
mvn clean package
docker build -t my-service:latest .
docker push registry.example.com/my-service:latest
```

```groovy
// build.gradle — moditect Gradle plugin creates the JLink image
plugins {
    id 'org.moditect.gradleplugin' version '1.3.0.Final'
}

moditect {
    createRuntimeImage {
        modulePath = [
            file("${buildDir}/libs"),
            tasks.jar.archiveFile
        ]
        modules = ['my.service']
        jarInclusionPolicy = 'NONE'
        launcher {
            name = 'myservice'
            module = 'my.service/com.example.Main'
        }
        noHeaderFiles = true
        noManPages = true
        stripDebug = true
        outputDirectory = file("${buildDir}/jlink-image")
    }
}

// Dockerfile
// FROM gcr.io/distroless/base-nossl-debian12
// COPY build/jlink-image /app/jrt
// ENV CLOUD=true
// ENTRYPOINT ["/app/jrt/bin/myservice"]

// Build and deploy
// gradle build
// docker build -t my-service:latest .
// docker push registry.example.com/my-service:latest
```

Tip:  You can also invoke  jlink  directly from the command line:  jlink --module-path target/libs --add-modules my.service --output target/jlink-image --strip-debug --no-header-files --no-man-pages . The moditect plugin simply wraps this into your build lifecycle.

### ~40-60 MB images

Distroless + JLink. No JDK, no shell.

### ~300 ms cold start

JRT skips JDK module scanning.

### JPackage installers

MSI, DEB, RPM, DMG. No JDK for end users.

### Module graph verified

Moditect validates the SPI graph at build time.

Lifecycle & environment

## Three-tier configuration — annotations → env vars → SPI

Override anything at deploy time without touching code.

Startup lifecycle

```mermaid
%%{init: {'theme': 'dark'}}%%
graph LR
    subgraph init ["Initialization"]
        A["GuiceApplication.run(Runnable)"] --> B["IGuiceConfigurator"]
        B --> C["IGuicePreStartup"]
    end
    subgraph discovery ["Discovery & Binding"]
        C --> D["ClassGraph Scan"]
        D --> E["IGuiceModule"]
    end
    subgraph runtime ["Runtime"]
        E --> F["Injector Creation"]
        F --> G["IGuicePostStartup"]
        G --> H["IGuicePreDestroy"]
    end

    style init fill:#29202a,stroke:#a94f78,color:#f5edf2
    style discovery fill:#202434,stroke:#777bc1,color:#f1f1f8
    style runtime fill:#192b27,stroke:#459e85,color:#eaf7f2
```

```mermaid
graph LR
    subgraph init ["Initialization"]
        A["GuiceApplication.run(Runnable)"] --> B["IGuiceConfigurator"]
        B --> C["IGuicePreStartup"]
    end
    subgraph discovery ["Discovery & Binding"]
        C --> D["ClassGraph Scan"]
        D --> E["IGuiceModule"]
    end
    subgraph runtime ["Runtime"]
        E --> F["Injector Creation"]
        F --> G["IGuicePostStartup"]
        G --> H["IGuicePreDestroy"]
    end

    style init fill:#29202a,stroke:#a94f78,color:#f5edf2
    style discovery fill:#202434,stroke:#777bc1,color:#f1f1f8
    style runtime fill:#192b27,stroke:#459e85,color:#eaf7f2
```

```java
# HTTP server
HTTP_ENABLED=true       HTTP_PORT=8080
HTTPS_ENABLED=false     HTTPS_PORT=8443
HTTPS_KEYSTORE=/path    HTTPS_KEYSTORE_PASSWORD=changeit
VERTX_MAX_BODY_SIZE=524288000

# Logging
CLOUD=true    LOG_LEVEL=INFO    DEBUG=true

# CORS
REST_CORS_ENABLED=true
REST_CORS_ALLOWED_ORIGINS=https://app.example.com

# Telemetry
TELEMETRY_SERVICE_NAME=my-service
TELEMETRY_OTLP_ENDPOINT=http://tempo:4318

# Database
DB_URL=jdbc:postgresql://db:5432/mydb
DB_USER=postgres    DB_PASSWORD=secret
```

### 1. Annotations

Sensible defaults in code —  @HealthOptions ,  @TelemetryOptions .

### 2. Environment vars

Override any annotation value at deploy time.

### 3. SPI hooks

Programmatic control —  VertxConfigurator ,  RestClientConfigurator .

Module deep-dives

## Every module has its own page

Full API docs, configuration reference, SPI hooks, and examples for each module.

Each GuicedEE module has its own dedicated page with full API documentation, configuration reference, SPI extension points, and code examples.

### REST services

@Path ,  @GET , CORS, security,  ExceptionMapper ,  RestInterceptor .

View documentation →

### REST client

@Endpoint ,  RestClient<S,R> , auth strategies, path params.

View documentation →

### Persistence

Hibernate Reactive 4.5 and ORM 7.4 ,  Mutiny ,  DatabaseModule , multi-db.

View documentation →

### Health

@Liveness ,  @Readiness ,  @Startup , env-var paths.

View documentation →

### Config

@ConfigProperty , source priority, env-var overrides.

View documentation →

### Vert.x core

EventBus , Verticles, Codecs, deployment.

View documentation →

### Web server

HTTP/HTTPS,  Router ,  BodyHandler , 3 SPI hooks.

View documentation →

### WebSockets

RFC 6455, action routing, group broadcast.

View documentation →

### RabbitMQ

Annotation-driven queues, exchanges, consumers.

View documentation →

### Kafka

Annotation-driven topics, consumers, publishers with Vert.x Kafka Client.

View documentation →

### IBM MQ

Annotation-driven queues, consumers, publishers with IBM MQ JMS.

View documentation →

### Telemetry

@Trace , OTLP export, Log4j2 correlation.

View documentation →

### Metrics

@Counted ,  @Timed , Prometheus endpoint.

View documentation →

### OpenAPI + Swagger

Auto-generated spec + browsable UI.

View documentation →

### GraphQL

SPI-driven HTTP + WebSocket + GraphiQL endpoints.

View documentation →

### Fault Tolerance

@Retry ,  @CircuitBreaker ,  @Timeout ,  @Bulkhead .

View documentation →

### CDI Bridge (Migration)

Migration aid:  @ApplicationScoped ,  @RequestScoped ,  BeanManager  →  Guice . Not a foundation module.

View documentation →

### Inject (core)

GuiceContext ,  ClassGraph , lifecycle SPI,  JobService .

View documentation →

Explore capabilities

Open the app builder

Browse All Examples

