Questions on Spring Boot – Part 3

Part 1  | Part 2 | Part 3

Questions on spring Boot

Recently many interview has a set of questions on Spring Boot when it comes to advanced Java Interviews. Here are frequently asked Spring Boot questions with answers.

  • What is Hot swapping in spring boot?

Reloading the changes without restarting the server is called hot swapping, Modern IDEs (Eclipse, IDEA, etc.) all support hot swapping of bytecode,  so if you make a change that doesn’t affect class or method signatures it should reload cleanly with no side effects.

  • How do you Switch off the Spring Boot security configuration?

If you define a @Configuration with @EnableWebSecurity anywhere in your application it will switch off the default webapp security settings in Spring Boot.

  • How to execute Spring Batch jobs on startup?

Spring Batch auto-configuration is enabled by adding @EnableBatchProcessing (from Spring Batch) somewhere in your context. By default it executes all Jobs in the application context on startup

  • Does spring boot need Logging? What is the default one?

Spring Boot has no mandatory logging dependency, except for the Commons Logging API.

  • How do you configure Configure Logback for logging?

If you put a logback.xml in the root of your classpath it will be picked up from there

  • How do you Configure Log4j for logging?

Spring Boot supports Log4j 2 for logging configuration if it is on the classpath. If you are using the starters for assembling dependencies that means you have to exclude Logback and then include log4j 2 instead

  • How do you write a Write a JSON REST service in spring boot?

Any Spring @RestController in a Spring Boot application should render JSON response by default as long as Jackson2 is on the classpath

  • How do you Write an XML REST service in spring boot?

If you have the Jackson XML extension (jackson-dataformat-xml) on the classpath, it will be used to render XML responses

  • What is the default Multipart File Uploads size in spring boot?

By default Spring Boot configures Spring MVC with a maximum file of 1MB per file and a maximum of 10MB of file data in a single request.

  • How do you Enable HTTP response compression in spring boot?

HTTP response compression is supported by Jetty, Tomcat, and Undertow. It can be enabled by adding server.compression.enabled=true in application.properties

  • How do you add Add a Servlet, Filter or Listener to an application ?

There are two ways to add Servlet, Filter, ServletContextListener and the other listeners supported by the Servlet spec to your application. You can either provide Spring beans for them, or enable scanning for Servlet components.

Questions on Spring boot- Part 1
Questions on Spring boot- Part 2
Questions on Spring boot- Part 3

Leave a Reply

Your email address will not be published. Required fields are marked *