이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 3. Creating the Getting Started project


The getting-started project lets you get up and running with a simple Quarkus application using Apache Maven and the Quarkus Maven plug-in.

Procedure

  1. In a command terminal, enter the following command to verify that Maven is using JDK 11 and that the Maven version is 3.6.2 or higher:

    mvn --version
    Copy to Clipboard Toggle word wrap
  2. 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.
  3. To generate the project, enter one of the following commands:

    Note

    Apple macOS and Microsoft Windows are not supported production environments.

    • If you are using Linux or Apple macOS, enter the following command:

      mvn io.quarkus:quarkus-maven-plugin:1.11.7.Final-redhat-00009:create \
          -DprojectGroupId=org.acme \
          -DprojectArtifactId=getting-started \
          -DplatformGroupId=com.redhat.quarkus \
          -DplatformVersion=1.11.7.Final-redhat-00009 \
          -DclassName="org.acme.quickstart.GreetingResource" \
          -Dpath="/hello"
      cd getting-started
      Copy to Clipboard Toggle word wrap
    • If you are using the Microsoft Windows command line, enter the following command:

      mvn io.quarkus:quarkus-maven-plugin:1.11.7.Final-redhat-00009:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started -DplatformGroupId=com.redhat.quarkus -DplatformVersion=1.11.7.Final-redhat-00009 -DclassName="org.acme.quickstart.GreetingResource" -Dpath="/hello"
      Copy to Clipboard Toggle word wrap
    • If you are using the Microsoft Windows Powershell, enter the following command:

      mvn io.quarkus:quarkus-maven-plugin:1.11.7.Final-redhat-00009:create "-DprojectGroupId=org.acme" "-DprojectArtifactId=getting-started" "-DplatformVersion=1.11.7.Final-redhat-00009" "-DplatformGroupId=com.redhat.quarkus" "-DclassName=org.acme.quickstart.GreetingResource" "-Dpath=/hello"
      Copy to Clipboard Toggle word wrap

      These commands create the following elements in the ./getting-started directory:

      • The Maven project directory structure
      • An org.acme.quickstart.GreetingResource resource exposed on /hello
      • Associated unit tests for testing your application in native mode and JVM mode
      • A landing page that is accessible on http://localhost:8080 after you start the application
      • Example Dockerfile.jvm, Dockerfile.native, and Dockerfile.fast-jar files in the src/main/docker directory
      • The application configuration file
  4. After the directory structure is created, open the pom.xml file in a text editor and examine the contents of the file:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.redhat.quarkus</groupId>
                <artifactId>quarkus-universe-bom</artifactId>
                <version>${quarkus.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <build>
      <plugins>
        <plugin>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-maven-plugin</artifactId>
          <version>${quarkus-plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>build</goal>
                <goal>generate-code</goal>
                <goal>generate-code-tests</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
     </plugins>
    </build>
    Copy to Clipboard Toggle word wrap

    The Quarkus BOM is included in the <dependencyManagement> section of the pom.xml file. Therefore, you do not need to list the versions of individual Quarkus dependencies in the pom.xml file. In addition, you can see the quarkus-maven-plugin plug-in that is responsible for packaging the application and providing the development mode.

  5. Review the quarkus-resteasy dependency in the pom.xml file. This dependency enables you to develop REST applications:

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>
    Copy to Clipboard Toggle word wrap
  6. Review the src/main/java/org/acme/quickstart/GreetingResource.java file:

    package org.acme.quickstart;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.MediaType;
    
    @Path("/hello")
    public class GreetingResource {
    
        @GET
        @Produces(MediaType.TEXT_PLAIN)
        public String hello() {
            return "hello";
        }
    }
    Copy to Clipboard Toggle word wrap

    This file contains a simple REST endpoint that returns hello as a response to a request that you send to the /hello endpoint.

    Note

    With Quarkus, the Application class for JAX-RS is supported but not required. In addition, only one instance of the GreetingResource class is created and not one per request. You can configure this by using different *Scoped annotations, for example ApplicationScoped, RequestScoped, and so forth.

You can create a Quarkus Maven project using the code.quarkus.redhat.com project generator. See Creating a Quarkus Maven project using code.quarkus.redhat.com for details.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동