I interviewed some people who said on their resumes that they were familiar with Spring Boot, or that they were learning Spring Boot. When I asked them, they only stayed at the stage of simple use, and many things were not clear, which also made me disappointed with the interviewees.

Below, I will summarize some Spring Boot interview questions that I often ask candidates. I hope they will help you.

1. What is Spring Boot?

Spring Boot is a sub-project of Spring open source organization. It is a one-stop solution for Spring components. It mainly simplifies the difficulty of using Spring, saves heavy configuration, and provides various initiators for developers to get started quickly.

2. Why Spring Boot?

Spring Boot has many advantages, such as:

Independent operation

Simplify the configuration

Automatic configuration

No code generation and XML configuration

Application of monitoring

The easier


With all these advantages, why not use Spring Boot?

3. What are the core configuration files of Spring Boot? What's the difference?

The core configuration files for Spring Boot are the Application and Bootstrap configuration files.

Application configuration file This is easy to understand and is mainly used for automatic configuration of Spring Boot projects.

The bootstrap configuration file can be used in the following scenarios.

When you use Spring Cloud Config to configure the configuration center, you need to add the configuration properties connected to the configuration center in the bootstrap configuration file to load the configuration information of the external configuration center.

Properties that are fixed and cannot be overridden;

Some encryption/decryption scenarios;

4. What are the formats of Spring Boot configuration files? What's the difference?

.properties and.yml, the main difference between them is the writing format.



In addition, the. Yml format does not support @propertysource annotation import configuration.

5. What are the core annotations for Spring Boot? Which notes are it mainly composed of?

The annotation above the Boot class is @SpringBootApplication, which is the core annotation of SpringBoot. The main combination contains the following three annotations:

6. What are the ways to enable Spring Boot?

1) Inherit the spring-boot-starter-parent project

2) Import the spring-boot-Dependencies dependencies project dependencies

7. Does Spring Boot need a separate container to run?

You don't need it, Tomcat/ Jetty containers are built in.

8.What are the ways to run Spring Boot?

1) Package with command or put in a container to run

2) Run the Maven/ Gradle plugin

3) Run the main method directly

9.What is the principle of Spring Boot automatic configuration?

The @enableAutoConfiguration, @Configuration, and @conditionalonClass annotations are at the heart of the auto-configuration, which must first be a Configuration file and then be automatically configured based on whether the class is present in the classpath.

10.What is the directory structure of Spring Boot?


This directory structure is the prevailing and recommended practice, while the @SpringBootApplication annotation on the main entry class enables SpringBoot capabilities such as automatic configuration, component scanning, and so on.

11. How do you understand the Starters in Spring Boot?

"Starters" is a set of "Starters" that can be integrated into your app, giving you a one-stop way to integrate Spring and other technologies without having to dig around for sample code and dependencies. If you want to use Spring JPA to access a database, simply add the spring-boot-starter-data-jPA initiator dependency.

"Starters" includes a lot of the dependencies that you'll need for projects that will run quickly and continuously, and are a set of supported, managed transitive dependencies.

How do I run some specific code when Spring Boot starts?

You can implement interfaces ApplicationRunner or CommandLineRunner, both of which are implemented in the same way, providing only a run method

13. What are the configuration reading methods available in Spring Boot?

Spring Boot can bind variables via @propertysource,@Value,@Environment, and @ConfigurationProperties

14. What logging frameworks does Spring Boot support? What are the recommended and default logging frameworks?

Spring Boot supports Java Util Logging, Log4j2, Lockback as the Logging framework, and if you use the Starters launcher, Spring Boot will use Logback as the default Logging framework.

15. What are the ways to implement hot deployment in SpringBoot?

There are two main ways:

Spring Loaded


16, How do you understand the Spring Boot configuration load order?

In Spring Boot, you can load configurations in the following ways.

1) Properties file;

2) YAML files;

3) System environment variables;

4) Command line parameters;

And so on...

17, Spring Boot how to define multiple sets of different environment configuration?

Provides multiple sets of configuration files, such as:





The runtime specifies the specific configuration file

18. Is Spring Boot compatible with old Spring projects?

Compatible, using the @importResource annotation to import the old Spring project configuration file.

19. What are the methods to protect Spring Boot applications?

Use HTTPS in production

Check your dependencies using Snyk

Upgrade to the latest version

Enable CSRF protection

Use content security policies to prevent XSS attacks


20.What's new with Spring Boot 2.X? What's the difference from 1.x?

Configuration changes

JDK Version Upgrade

Upgrade the third-party class library

Responsive Spring programming support

Support HTTP / 2

Configuring property Binding

More improvements and enhancements...

Finally finished writing, I hope you study hard before going to the interview, otherwise the interviewer asked these questions, and can not answer it will be embarrassing. Understanding these issues will also help you understand Spring Boot.

These 20 interview questions are for season 1, and more Spring Boot/Cloud related interview questions will be compiled later.

Categories: Spring Boot