Questions on Spring Boot – Part 3

  • 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.

//不是affect class or method signatures的话, 举个具体的例子

  • 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

// 详细,log有必要写blog或者github project,

  • 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

//详细,log有必要写blog或者github project,

//需要比较一下 logback和log4j吗?怎么include log4并且exclude logback

  • 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

//是不是要比较一下两者? github project

  • 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

//  server compression 有什么作用?

  • 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.

  • How do you Change tomcat or jetty HTTP port?

You can change the tomcat http port by changing default http property in file.