Features of Spring Boot

Fig : Features of Spring Boot

SpringApplication :

    The SpringApplication class provides a convenient way to bootstrap a Spring application that is started from a main() method.

                                            
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class MyApplication {
    
        public static void main(Spring[] args) {
            SpringApplication.run(MyApplication.class, args);
        }
    }
                                            
                                        

Externalized Configuration :

  • Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments.
  • You can use a variety of external configuration sources, include Java properties files, YAML files, environment variables, and command-line arguments.

It is recommended to stick with one format for your entire application. If you have configuration files with both .properties and .yml format in the same location, .properties takes precedence.

Profiles :

  • Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments.
  • Any @Component, @Configuration or @ConfigurationProperties can be marked with @Profile to limit when it is loaded, as shown in the following example:
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Profile;
    
    @Configuration(proxyBeanMethods = false)
    @Profile("production")
    public class ProductionConfiguration {
    
        // ... 
    
    }
                                        

Logging :

  • Logging is a very important part of any application and it helps with debugging issues.
  • Spring Boot, by default, includes spring-boot-starter-logging as a transitive dependency for the spring-boot-starter module.
  • You can easily configure logging levels within the application.properties file as INFO, DEBUG, ERROR, WARN, TRACE.
    logging.level.org.springframework.web=INFO
    logging.level.org.hibernate=ERROR
    logging.level.com.example=DEBUG
                                        

Internationalization :

    Internationalization allows spring boot to make application adaptable to different languages and regions, such that same source code can be used in different countries having different languages.

JSON :

  • Spring Boot provides integration with three JSON mapping libraries:
  • Gson, Jackson, JSON-B
  • Jackson is the preferred and default library.

Testing :

  • Spring Boot provides a number of utilities and annotations to test your application.
  • Test support is provided by two modules: spring-boot-test which contains core items, and spring-boot-test-autoconfigure.
  • Most developers use the spring-boot-starter-test “Starter”, which imports all useful libraries.