此内容没有您所选择的语言版本。
Chapter 3. Creating a Quarkus project on the command line
You can use the Quarkus Maven plug-in on the command line to create a Quarkus project by providing attributes and values on the command line or by using the plug-in in interactive mode. The resulting project will contain the following elements:
- The Maven structure
- An associated unit test
-
A landing page that is accessible on
http://localhost:8080after you start the application -
Example
Dockerfilefiles for JVM and native mode insrc/main/docker - The application configuration file
Procedure
In a command terminal, enter the following command to verify that Maven is using JDK 11 and that the Maven version is 3.6.3 or higher:
mvn --version
mvn --versionCopy to Clipboard Copied! Toggle word wrap Toggle overflow - If the preceding command does not return JDK 11, add the path to JDK 11 to the PATH environment variable and enter the preceding command again.
To use the Quarkus Maven plug-in to create a new project, use one of the following methods:
Enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this command, replace the following values:
-
<project_group_id>: A unique identifier of your project -
<project_artifact_id>: The name of your project and your project directory -
<classname>: The fully qualified name of the generated resource, for exampleorg.acme.quarkus.sample.HelloResource
-
Create the project in interactive mode:
mvn io.quarkus:quarkus-maven-plugin:1.7.6.Final-redhat-00014:create
mvn io.quarkus:quarkus-maven-plugin:1.7.6.Final-redhat-00014:createCopy to Clipboard Copied! Toggle word wrap Toggle overflow When prompted, enter the required attribute values.
NoteAlternatively, you can create your project using the default values for the project attributes by entering the following command:
mvn io.quarkus:quarkus-maven-plugin:1.7.6.Final-redhat-00014:create -BThe following table lists the attributes that you can define with the
createcommand:Expand Attribute Default Value Description projectGroupIdorg.acme.sampleA unique identifier of your project.
projectArtifactIdnone
The name of your project and your project directory. If you do not specify the
projectArtifactId, the Maven plug-in starts the interactive mode. If the directory already exists, the generation fails.projectVersion1.0-SNAPSHOTThe version of your project.
platformGroupIdio.quarkusThe group id of your platform. All the existing platforms are provided by
io.quarkus. However, you can change the default value.platformArtifactIdquarkus-universe-bomThe artifact id of your platform BOM. To use the locally built Quarkus add
quarkus-universe-bomto yourpom.xmlfile.platformVersionThe latest platform version
The version of the platform you want to use for your project. You can provide a version range and the Maven plug-in uses the latest version.
classNameNone
The fully qualified name of the generated resource. After the application is created, the REST endpoint is exposed at the following URL:
http://localhost:8080/$pathIf you use the default
path, the URL ishttp://localhost:8080/hello.path/helloThe resource path, only if you set the
className.extensions[]
The list of extensions you want to add to your project separated by comma.
By default, the Quarkus Maven plug-in uses the latest quarkus-universe-bom file. This BOM aggregates extensions so you can reference them from your applications to align the dependency versions. If you are offline, the Quarkus Maven plug-in uses the latest locally available version of the quarkus-universe-bom. If Maven finds the quarkus-universe-bom version 2.0 or earlier, it will use the platform based on the quarkus-universe-bom.