[Turn] 20 Spring Boot face questions

Interview a small number of people, say they resume the familiar Spring Boot, or say when are learning Spring Boot, I asked them, use only stay in a simple stage, many things are not clear, let me disappointed for the interviewer.

Here, I give everyone what Spring Boot summary of interview questions, which I often used to ask the interviewer, I hope to help you.

1. What is Spring Boot?

Spring Boot is a sub-project of the Spring open source organizations, is Spring component stop processing programs, mainly to simplify the difficulty of using Spring, Jane, heavy configuration, offers a variety of starters, developers can quickly get started.

 

2. Why use Spring Boot?

Spring Boot advantages are many, such as:

Operate independently

Simplified configuration

Automatic Configuration

XML configuration and no code generation

Application Monitoring

Easy to get started

Spring Boot set so many advantages not use it all in one, there are reasons for it?

3, Spring Boot core configuration files and which of? What is the difference between them?

Spring Boot application file is the core configuration and bootstrap configuration file.

application configuration file that is easy to understand, is mainly used for automation Spring Boot project configuration.

bootstrap configuration file There are several scenarios.

When using Spring Cloud Config distribution center, then the need to increase the connection configuration information to the configuration properties configured to load external configuration centered on the center of the bootstrap configuration file;

A small amount can not be covered by the fixed property;

A small amount of encryption / decryption of the scene;

 

4, Spring Boot configuration file, which has several formats? What's the difference?

.properties and .yml, the main difference between them is written in a different format.

1).properties

2) .yml

In addition, .yml format does not support @PropertySource notes import configuration.

5, the core notes Spring Boot Which? It mainly consists of several notes which composed?

Start class above comment is @SpringBootApplication, it also notes Boot Spring core, the main combination contains the following three notes:

@SpringBootConfiguration: @Configuration combination of notes, functional configuration file.

@EnableAutoConfiguration: Open autoconfiguration function can also turn off an option automatically configured, such as closing a data source Auto Configuration: @SpringBootApplication (exclude = {DataSourceAutoConfiguration.class}).

@ComponentScan: Spring component scans.

6, open Spring Boot characteristics, which has several ways?

1) inherited spring-boot-starter-parent project

2) introduced into the spring-boot-dependencies project dependencies

 

7, Spring Boot requires a separate container to run it?

May not be required, it built Tomcat / Jetty like container.

8, run Spring Boot What are the different ways?

1) were packed into a container or a command running

2) Run with Maven / Gradle plugin

3) run directly execute the main method

9. What Spring Boot automatically configure principle?

Notes @EnableAutoConfiguration, @Configuration, @ConditionalOnClass core is automatically configured, first of all it's gotta be a configuration file, followed by the ability to have the class to automatically configured according to the classpath.

 

10, the directory structure is how the Spring Boot?

The directory structure is the mainstream and recommended practices, and in the main entrance class plus the ability to turn @SpringBootApplication comment Spring Boot, such as automatic configuration, scanning and other components.

11. How do you know Spring Boot in Starters?

Starters can understand as a starter, which contains a series of applications which can be integrated into the dependencies, you can stop and rest Spring integration technology, without the need for looking around for sample code and dependencies. If you want to use the Spring JPA to access the database, only the addition of spring-boot-starter-data-jpa starter depend ready to use.

Starters include the dependence of many projects need to use, they can continue to run fast, are supported by a series of management transitive dependencies.

12, how to run a small amount of code at a particular time Spring Boot start?

Alternatively the interface may be implemented by ApplicationRunner CommandLineRunner, as these two interfaces implementations, they only provide a run method,

13, Spring Boot There are several ways to read the configuration of what?

Spring Boot can bind variables @ PropertySource, @ Value, @ Environment, @ConfigurationProperties,

14, Spring Boot which supports logging framework? The default logging framework and recommend which?

Spring Boot support Java Util Logging, Log4j2, Lockback as a logging framework, if you are using Starters starter, Spring Boot will be used as the default log Logback framework,

15, SpringBoot achieve hot deployment, which has several ways?

There are two main ways:

Spring Loaded

Spring-boot-devtools

Spring-boot-devtools?

16. How do you know Spring Boot Configuration load order?

In Spring Boot which may be several ways to load configuration.

1) properties file;

2) YAML files;

3) system environment variables;

4) command line parameters;

and many more……

 

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

It offers multiple configuration files, such as:

 

Assign specific run-time configuration file

18, Spring Boot compatible with the old Spring projects do, how to do?

Compatible, use @ImportResource annotation project to import old Spring configuration file.

19, which has a protective Spring Boot method of application?

Use HTTPS in production

Use Snyk check your dependencies

Update to the latest version

Enable CSRF protection

Use content security policies to prevent XSS attacks

 

20, Spring Boot 2.X What is New? And 1.X What is the difference?

Configuration changes

JDK version update

Third-party libraries update

Spring responsive programming support

HTTP / 2 support

Binding Configuration Properties

More improvements and enhancements ...

Finally finished, I hope you learn to go to the next interview, or interviewer ask these questions again, but not answer the question embarrassing. Understand these problems, you know Spring Boot also has a very big help,

This 20 interview questions even in the first quarter it back will organize more season Spring Boot / Cloud-related interview questions.

Guess you like

Origin www.cnblogs.com/zouwangblog/p/10984901.html