Skip to content
Jan Meznarič edited this page Apr 26, 2019 · 11 revisions

Uber JAR support - Pack and run microservice as uber JAR

KumuluzEE (since version 2.4.0) provides support for packing and running microservices as uber JARs. It also includes a Maven plugin that correctly packages the microservice.

To package a KumuluzEE microservice into an uber JAR, you need to add the following plugin declaration into your REST module pom.xml:

<plugin>
    <groupId>com.kumuluz.ee</groupId>
    <artifactId>kumuluzee-maven-plugin</artifactId>
    <version>${kumuluzee.version}</version>
    <executions>
        <execution>
            <id>package</id>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Goals supported by plugin

  • kumuluzee:copy-dependencies

    Copy dependencies and prepare for execution in an exploded class and dependency runtime.

  • kumuluzee:repackage

    Repackages existing JAR archives so that they can be executed from the command line using java -jar.

    Parameters
    • finalName

      Final name of the generated "uber" JAR.

      Default value is: ${project.build.finalName} or ${project.artifactId}-${project.version}

    • outputDirectory

      Directory containing the generated JAR.

      Default value is: ${project.build.directory}

  • kumuluzee:run

    Run the application in an exploded class and dependency runtime.

Manual execution of plugin

If execution is not provided in kumuluzee-maven-plugin:

<plugin>
    <groupId>com.kumuluz.ee</groupId>
    <artifactId>kumuluzee-maven-plugin</artifactId>
    <version>${kumuluz.version}</version>
</plugin>

then you have to explicitly run

mvn kumuluzee:repackage

with desired goal after mvn package to trigger the plugin.

Run

Start the application using the following command:

java -jar ${project.build.finalName}.jar

Example:

java -jar my-app-1.0.0-SNAPSHOT.jar

or by using the run goal of the KumuluzEE maven plugin.

Package as exploded by plugin

To package a KumuluzEE microservice as exploded, you can use the following configuration of the plugin in REST module pom.xml:

<plugin>
    <groupId>com.kumuluz.ee</groupId>
    <artifactId>kumuluzee-maven-plugin</artifactId>
    <version>${kumuluz.version}</version>
    <executions>
        <execution>
            <id>package</id>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Run

Start the application packaged as exploded using the following command:

java -cp target/classes:target/dependency/* com.kumuluz.ee.EeApplication

in Windows environment use the command:

java -cp target/classes;target/dependency/* com.kumuluz.ee.EeApplication