You can create your getting-started project by using the Quarkus command-line interface (CLI).
With the Quarkus CLI, you can create projects, manage extensions, and run build and development commands.
|
Important: The Quarkus CLI is intended for development purposes, including tasks such as creating, updating, and building Quarkus projects. However, IBM does not support using the Quarkus CLI in production environments. |
-
You have the Quarkus CLI installed. For installation instructions, see CLI tooling.
-
You have configured your Quarkus developer tools to access extensions in the extension registry. For more information, see Configuring IBM Enterprise Build of Quarkus extension registry client.
-
To generate the project, in a command terminal, enter the following command:
quarkus create && cd code-with-quarkusNote: You can also specify the 'app' subcommand, for example,
quarkus create app. However, it is not mandatory to do so because the 'app' subcommand is implied if it is not specified.With this command, you create the Quarkus project in a folder called
code-with-quarkusin your current working directory. -
By default, the
groupId,artifactId, andversionattributes are specified with the following default values:-
groupId='org.acme'
-
artifactId='code-with-quarkus'
-
version='1.0.0-SNAPSHOT'
To change the values of the
groupId,artifactId, andversionattributes, issue thequarkus createcommand and specify the following syntax on the CLI:groupId:artifactId:versionFor example,
quarkus create app mygroupId:myartifactid:version
Note: To view information about all the available Quarkus commands, specify the
helpparameter:quarkus --help -
-
Review the
src/main/java/org/acme/GreetingResource.javafile in a text editor:package org.acme; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @Path("/hello") public class GreetingResource { @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return "Hello from Quarkus REST"; } }This file contains a simple REST endpoint that returns
Hello from Quarkus RESTas a response to a request that you send to the/helloendpoint.
-
Run the application in a command terminal.
quarkus dev-
In a new terminal, call the endpoint:
curl -w "\n" http://localhost:8080/helloThe response is:
Hello from Quarkus REST
-
-
Make a live code change to confirm the dev-mode feedback loop. For example, change the returned string to something else (for example,
"Hello, world!") and save the file. Then re-run thecurlcommand.