Spring boot web app configuration

As we discussed in earlier tutorials that spring boot will take care of all boilerplate code, so it will provide all configurations automatically. But we can change the default configurations.

Spring boot change default tomcat port

Default HTTP port in spring boot application is 8080. We can change it by overriding the default port in the application.properties file.


Spring boot change context path

Default context path in spring boot application is “/”. We can change it by overriding the default port in the application.properties file.


Spring boot configure log level

We can configure the logging levels in the application.properties file.


Shut down a boot application pro-grammatically

We can shut down a boot application programmatically with SpringApplication class. It provides static exit() method which takes two arguments (ApplicationContext and an ExitCodeGenerator).

public void shutDown(ExecutorServiceExitCodeGenerator exitCodeGenerator) {
    SpringApplication.exit(applicationContext, exitCodeGenerator);

Spring boot configure jetty

Default embedded server in spring boot application is apache tomcat. We can change it, we are using jetty server here.

public JettyEmbeddedServletContainerFactory  jettyEmbeddedServletContainerFactory() {
    JettyEmbeddedServletContainerFactory jettyContainer = 
      new JettyEmbeddedServletContainerFactory();
    return jettyContainer;
Please follow and like us:
Content Protection by DMCA.com