- Spring Boot - Google OAuth2 Sign-In
- Spring Boot - Google Cloud Platform
- Spring Boot - OAuth2 with JWT
- Securing Web Applications
- Spring Boot - Database Handling
- Rest Controller Unit Test
- Spring Boot - Unit Test Cases
- Spring Boot - Twilio
- Spring Boot - Apache Kafka
- Spring Boot - Batch Service
- Spring Boot - Web Socket
- Spring Boot - Hystrix
- Spring Boot - Sending Email
- Spring Boot - Flyway Database
- Tracing Micro Service Logs
- Spring Boot - Creating Docker Image
- Spring Boot - Enabling Swagger2
- Spring Boot - Admin Client
- Spring Boot - Admin Server
- Spring Boot - Actuator
- Spring Cloud Configuration Client
- Spring Cloud Configuration Server
- Zuul Proxy Server and Routing
- Service Registration with Eureka
- Spring Boot - Eureka Server
- Spring Boot - Enabling HTTPS
- Spring Boot - Scheduling
- Spring Boot - Internationalization
- Spring Boot - CORS Support
- Consuming RESTful Web Services
- Spring Boot - Thymeleaf
- Spring Boot - Service Components
- Spring Boot - File Handling
- Spring Boot - Rest Template
- Spring Boot - Tomcat Port Number
- Spring Boot - Servlet Filter
- Spring Boot - Interceptor
- Spring Boot - Exception Handling
- Building RESTful Web Services
- Spring Boot - Logging
- Spring Boot - Application Properties
- Spring Boot - Runners
- Spring Beans & Dependency Injection
- Spring Boot - Code Structure
- Spring Boot - Build Systems
- Spring Boot - Tomcat Deployment
- Spring Boot - Bootstrapping
- Spring Boot - Quick Start
- Spring Boot - Introduction
- Spring Boot - Home
Spring Boot Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Spring Boot - Quick Start
This chapter will teach you how to create a Spring Boot apppcation using Maven and Gradle.
Prerequisites
Your system need to have the following minimum requirements to create a Spring Boot apppcation −
Java 7
Maven 3.2
Gradle 2.5
Spring Boot CLI
The Spring Boot CLI is a command pne tool and it allows us to run the Groovy scripts. This is the easiest way to create a Spring Boot apppcation by using the Spring Boot Command Line Interface. You can create, run and test the apppcation in command prompt itself.
This section explains you the steps involved in manual installation of Spring Boot CLI. For further help, you can use the following pnk:
You can also download the Spring CLI distribution from the Spring Software repository at:
For manual installation, you need to use the following two folders −
spring-boot-cp-2.0.0.BUILD-SNAPSHOT-bin.zip
spring-boot-cp-2.0.0.BUILD-SNAPSHOT-bin.tar.gz
After the download, unpack the archive file and follow the steps given in the install.txt file. Not that it does not require any environment setup.
In Windows, go to the Spring Boot CLI bin directory in the command prompt and run the command spring –-version to make sure spring CLI is installed correctly. After executing the command, you can see the spring CLI version as shown below −
Run Hello World with Groovy
Create a simple groovy file which contains the Rest Endpoint script and run the groovy file with spring boot CLI. Observe the code shown here for this purpose −
@Controller class Example { @RequestMapping("/") @ResponseBody pubpc String hello() { "Hello Spring Boot" } }
Now, save the groovy file with the name hello.groovy. Note that in this example, we saved the groovy file inside the Spring Boot CLI bin directory. Now run the apppcation by using the command spring run hello.groovy as shown in the screenshot given below −
Once you run the groovy file, required dependencies will download automatically and it will start the apppcation in Tomcat 8080 port as shown in the screenshot given below −
Once Tomcat starts, go to the web browser and hit the URL http://localhost:8080/ and you can see the output as shown.
Advertisements