Chapter 2. Creating the Spring Web example Maven project


You can create a new Quarkus project, automatically generate the REST controller class, and add the quarkus-spring-web dependency with a single command using the Quarkus Maven plugin. You can also update the pom.xml file and create the REST controller class and the REST controller test class manually.

Procedure

  • Use one of the following approaches that are shown shown in this section to create your Quarkus Spring Web example Maven project:

    • If you do not have a Maven project, you can create a new Maven project using the Quarkus Maven plugin. Enter the following command to:

      • Create the Maven project directory structure
      • Create the org.acme.spring.web.GreetingController class that defines a REST endpoint for your application
      • Import the quarkus-spring-web extension

        You must replace <project_name> with the name of the directory that contains your project files.

        mvn io.quarkus:quarkus-maven-plugin:1.11.7.Final-redhat-00009:create \
            -DprojectGroupId=org.acme \
            -DprojectArtifactId=<project_name> \
            -DclassName="org.acme.spring.web.GreetingController" \
            -Dpath="/greeting" \
            -Dextensions="spring-web"
    • If you already have a Quarkus Maven project, you must add the quarkus-spring-web extension to it using the command line:
    1. Navigate to the root directory of your project:

      cd <project_name>
    2. Add the quarkus-spring-web extension to the pom.xml file of your project:

      ./mvnw quarkus:add-extension -Dextensions="spring-web"

      With this command you add the following entry to your pom.xml file:

      pom.xml

      <dependency>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-spring-web</artifactId>
      </dependency>

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.