Spring Boot essential features

Posted By :Shivani Chaudhary |27th January 2020


Spring Boot quite gets away all these anxieties and allows you to write the code which implies that is application code. Each feature of the Spring Boot which I noticed Example. auto-configuration, Starter POMs or Starter dependency and Spring Boot CLI proposes to analyze Java development with Spring.

Instantly, let's operate into a slight bit more details on an individual of certain features:

 

1. AutoConfiguration

You may have worked among Spring-based Java web applications which equates to a relational database Exmaple: an in-memory database similar to H2 and if yes later you might know that you require to declare JdbcTemplate as a bean and also need to configure a DataSource which means a dependency for JdbcTempalte.

During a modern-day Spring application, which applies Java-based configuration, you need to combine the following two methods into your Configuration class:

@Bean
public JdbcTemplate jdbcTempalte(DateSource ds){
   return new JdbcTempalte(ds);
}

@Bean
public DataSource dataSource(){
  return new EmbeddedDatabaseBuilder()
     .setType(EmbeddedDatabaseType.H2)
     .addScripts('ddl.sql', 'data.sql')
     .build();
}


 @EnableAutoConfiguration or @SpringBootApplication annotation proceeding to Configuration class. I commonly annotated the Main class, which I am continuing to run with an set Tomcat server.

 

2. Starter POMs

While AutoConfiguration brings away the effort of configuring common functionalities, the Starter POMs take away the effort by finding and combining common dependencies in your project.

To build a simplistic Spring MVC based REST application which supports Jackson and to run it an embedded container, you would at least want following dependencies Example:

spring-core.jar
spring-web.jar
spring-webmvc.jar
jackson-databind.jar
tomcat-embed-core.jar
tomcat-embed-el.jar
tomcat-embed-logging-juil.jar

By applying Spring Boot Starter POMs or starter dependency feature, you can perceive all of these by just appending spring-boot-starter-web dependency in your pom.xml


So, instead of appending all these dependencies and suffering about their compatible version, you just require to attach one. You wish also to be more confident that analyzed and tested versions of libraries are used. there won't be some incompatibility issues in the future.

 

3. Spring Boot CLI

While auto-configuration and starter dependencies are a primary focus on Spring Boot, Spring CLI is an optional one, you also require to install Spring CLI to use it.

Here is a simplistic "HelloWorld" RESTful Web Service in Groovy and Spring Boot CLI and it works you can only run even externally compiling as shown below:

@RestController
class HelloSpringBootController {

  @RequestMapping("/")
  def helloWorld() {
    return "Hello Spring Boot CLI"
   }
}

Done, you can run this on an embedded container that appears including Spring Boot CLI, no web.xml, no configuration, and no server setup.


 

4. Actuator

The actuator is another remarkable feature of Spring Boot which enables seeing what's performing on inside a running Spring Boot application. Among all its goodness of auto-configuration, there comes a risk of not knowing what is inside your application and that risk is addressed by Spring Actuator.

It gives a lot of insights and metrics of a running application in production. For example, by applying Actuator you can get out exactly which beans are configured in the Application context, whatever are auto-configuration decisions made, whichever environment variables, system properties, command-line arguments are available to an application including many more.

 

5. Spring Boot Initializer

Spring Initializer is another feature of Spring Boot which resolves the problem concerning the project structure. Such a web application that enables yourself to create a Maven or Gradle project with Java, Kotlin or Groovy including Spring Boot.

All you require to define is to provide Project MetaData in GUI Example: name of your project, Group, Artifact, etc. It also enables you to choose a starter dependency from a big list Example: web, JPA, or security starter.

Once you build a project you can download the Zip file also next to open into an IDE like Eclipse or IntelliJ IDEA as described in Spring Boot. 

 

Thanks.

 


About Author

Shivani Chaudhary

Shivani is a quick learner, self problem-solving, quickly grasp new things and hard-working Java Developer. She has good knowledge about Java, Spring MVC, Spring boot, Spring Data JPA, Hibernate, REST Web Services. Her hobbies are travelling and learning

Request For Proposal

Sending message..

Ready to innovate ? Let's get in touch


Notice: Undefined index: HTTP_REFERER in /var/html/www/AI/wp-content/themes/oxides-child/functions.php on line 272

Notice: Undefined index: HTTP_REFERER in /var/html/www/AI/wp-content/themes/oxides-child/functions.php on line 272

Notice: Undefined index: HTTP_REFERER in /var/html/www/AI/wp-content/themes/oxides-child/functions.php on line 272

Notice: Undefined index: HTTP_REFERER in /var/html/www/AI/wp-content/themes/oxides-child/functions.php on line 272

Chat With Us