Setting up the application build

Whatever pom.xml we have used until now is enough to execute our sample REST service. This service would package the code into a JAR. To make this JAR executable we need to opt for the following options:

Running the Maven tool

Here, we use the Maven tool to execute the generated JAR, steps for the same are as follows:

  1. Right-click on the pom.xml.
  2. Select run-maven | Goals… from the pop-up menu. It will open the dialog. Type spring-boot:run in the Goals field. We have used the released version of Spring Boot in the code. However, if you are using the snapshot release, you can check the Update Snapshots checkbox. To use it in the future, type spring-boot-run in the Remember as field.
  3. Next time, you could directly click run-maven | Goals | spring-boot-run to execute the project:
    Running the Maven tool

    Run Maven dialog

  4. Click on OK to execute the project.

Executing with the Java command

To build the JAR, perform the mvn clean package Maven goal. It creates the JAR file in a target directory, then, the JAR can be executed using the command:

java -jar target/restsample-1.0-SNAPSHOT.jar
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset