Getting started with Spring Boot

To understand and to work with Spring Boot better, it is good to have a decent knowledge of Java, Spring framework and one of Maven/Gradle. Note that Spring Boot is just a convenient way to do Spring.

 

Starter POMs

There are various starter pom dependencies such as spring-boot-starter, spring-boot-starter-web and spring-boot-starter-jdbc etc., that will add all dependencies and provide even default configurations based on which starter pom we have selected. You can create a simple maven project and add the Spring boot starter parent and starter pom dependency to the build file.

For sample code and the dependencies for creating a simple web application, you can refer to the Quick Start section @ https://projects.spring.io/spring-boot/. Note that the main method is the starting point to a Spring Boot application, even if it is a web application. SpringApplication.run() method is responsible for starting spring, creating spring context, applying annotations and setting up container.

Also, even though not specified in the example, @SpringBootApplication annotation can be used for creating a Spring Boot application and wraps other commonly used annotations including @Configuration, @EnableAutoConfiguration and @ComponentScan.

 

start.spring.io

You can go to the link https://start.spring.io/ and configure and create a simple Spring Boot project with all dependencies automatically added based on the options selected.

You can also use an IDE that provides Spring Boot support such as Spring STS or Intellij, which internally connects to start.spring.io. With Intellij IDEA IDE, you can go to create new project and on the first page of the New Project wizard, select Spring Initializr in the left pane.

Spring Boot ships with a command line tool (Spring Boot CLI) that can be used if you want to quickly prototype with Spring. It allows you to run Groovy scripts, which means that you have a familiar Java-like syntax, without so much boilerplate code. You can install it by following: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#getting-started-installing-the-cli. Spring Boot CLI also internally connects to start.spring.io.

You can create a spring boot application MyABCAppln with a starter-web dependency as:

./spring init –dependencies=web MyABCAppln.

 

Spring Boot Samples

Spring also provides a set of sample Spring boot applications in their github repo. Find more @ https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples. Just clone and use them.

Comments

Logistics Pioneer’s since last 15 years. GRL ENGINEERS was formed with a clear focus on development of road safety products.
speed governor

Was it useful?

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!