Installing Spring Boot and other Software
We will be developing a web application with the spring-boot framework and it requires some software to get started with development. We expect you to have the Java environment setup before getting the other software. It uses dependency management techniques such as maven which is very easy when used with an IDE like Eclipse etc.
In the upcoming tutorials, we will be using Java 8, Maven (dependency management), Eclipse IDE for the development examples.
Although we use maven from the Eclipse IDE, we may need the installation when the project is exported as a JAR file to run from the CMD (Command line prompt).
After downloading the Maven ZIP file, extract it to some folder on your drive and switch to bin directory.
Hit the command
mvn -v, after switching to bin directory inside the maven installation folder to check the version.
The above figure displays the maven and java version respectively. It is advisable to set the environment path for maven bin folder just as same as java environment setup.
Spring Boot CLI:
As a quick example on production-ready spring-based applications, let us look at the Spring-boot CLI(command line interface). We need to download spring-boot CLI. After extracting the ZIP file, switch to the bin directory from the command line and enter the command
The above figure displays the version of the spring-boot CLI and make sure to check the version after switching to bin directory of spring-boot CLI. Now, let us create a file studytonight.groovy in the bin directory. Place the below code in the groovy file and save.
public String displayWelcomeMessage()
return "Welcome to spring-boot tutorials!!";
In the CMD, under bin directory path, run the command spring run studytonight.groovy which runs the application on embedded tomcat on port 8080.
In the above image, we received the response from the embedded tomcat which spring-boot has auto-configured. The important point to note is even we did not include any import statements in the groovy file but the Spring-Boot CLI has resolved dependencies for us.
REST Client Installation:
In order to test the RESTful web services, we need a REST client which will be used to send request and receive response. One of such rest clients is POSTMAN. It has gained a lot of importance because of the easy and convenient way to use it.
For GET requests, it is possible to hit the API just by entering the URL in the browser itself. For POST requests, it is required to use some REST CLIENT as it is not possible to hit the API by pasting the URL in the browser.
- After downloading and launching the postman, we can see the UI which is similar to the below figure 2.4.
Conclusion: In this tutorial, we have seen the installation of the required software to proceed with the web application development using spring-boot. Apart from creating a web application, we will also create simple console application as well. In the next tutorial, we will set up the project and import it to Eclipse IDE.