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 by 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 to create your Quarkus Spring Web example Maven project:
If you do not have a Maven project, you can create a new Maven project by using the Quarkus Maven plugin. Enter the following command to complete the following actions:
- Create the Maven project directory structure
-
Create the
org.acme.spring.web.GreetingControllerclass that defines a REST endpoint for your application Import the
quarkus-spring-webextensionYou must replace
<project_name>with the name of the directory that contains your project files.mvn com.redhat.quarkus.platform:quarkus-maven-plugin:2.2.5.Final-redhat-00007: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-webextension to it by using the command line:
Navigate to the root directory of your project. Enter the following command:
cd <project_name>Add the
quarkus-spring-webextension to thepom.xmlfile of your project. Enter the following command:./mvnw quarkus:add-extension -Dextensions="spring-web"The following entry is added to your
pom.xmlfile:pom.xml
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-spring-web</artifactId> </dependency>