Saturday 21 July 2018

SpringApplicationBuilder tutorial

SpringApplicationBuilder used to generate SpringApplication and ApplicationContext instances.

Example
ConfigurableApplicationContext applicationContent = new SpringApplicationBuilder(Application.class).child(Application.class).web(WebApplicationType.NONE).bannerMode(Banner.Mode.CONSOLE).logStartupInfo(false).run(args);

Application.java

package com.sample.myApp;

import org.springframework.boot.Banner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Application {

 public static void main(String args[]) {
  ConfigurableApplicationContext applicationContent = new SpringApplicationBuilder(Application.class)
    .child(Application.class).web(WebApplicationType.NONE).bannerMode(Banner.Mode.CONSOLE)
    .logStartupInfo(false).run(args);

  applicationContent.close();
 }
}



Previous                                                 Next                                                 Home

No comments:

Post a Comment