Spring Boot


Spring Boot provides the convention over the configurations and highly helpful to build the application with minimal configurations and minimum effort by developer.

In this tutorial we are starting with the setup of the spring boot application.

Let's see go through the basic annotation we use more often,

@SpringBootApplication is a convenience annotation that adds all of the following:

  • @Configuration tags the class as a source of bean definitions for the application context.
  • @EnableAutoConfiguratuon enables Spring Boot to start adding beans based on classpath settings, other beans, and other property settings.
  • @ComponentScan enables Springboot to look for other components, configurations, and services in the package, allowing it to find the controllers.
  • @EnableWebMvc In generally we will add this to create a spring mvc app. But sptongboot adds it automaticallu when it identifies spring-webmvc on the classpath. It makes the application as a web application and activates the behaviours such as setting up DispatcherServlet
What you’ll need
  • About 13 minutes
  • A text editor or IDE (STS)
  • The Java Development Kit (JDK), version 1.8 or higher
  • Gradle distribution, version 4.6 or later
  • You can also import the code directly into the IDE

Lets create the project with Gradle as following :

gradle-spring-boot-project
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   └── java
    │       └── Sample.java
    └── test
        └── java

            └── SampleTest.java


No comments:

Post a Comment