Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interview questions for the latest version of Spring Boot in 2021

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "what are the interview questions for the latest version of 2021 Spring Boot". In daily operation, I believe many people have doubts about the interview questions of the latest version of 2021 Spring Boot. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "what are the interview questions of the latest version of 2021 Spring Boot?" Next, please follow the editor to study!

1. What is SpringBoot? With Spring Boot, you can easily create stand-alone, production-level Spring-based applications that you can "run". Most Spring Boot applications require minimal Spring configuration.

two。 Why use SpringBoot?

Rapid development, rapid integration, simplified configuration, embedded service containers

3. The difference between SpringBoot and SpringCloud

SpringBoot is a rapidly developing Spring framework, SpringCloud is a complete micro-service framework, and SpringCloud depends on SpringBoot.

4. What are the advantages of Spring Boot?

Spring Boot has the following main advantages:

Easy to use, improve development efficiency, and provide a faster and simpler development framework for Spring development.

Use right out of the box, away from tedious configuration.

It provides a series of common non-business functions for large-scale projects, such as embedded server, security management, operation data monitoring, health check and externalization configuration.

SpringBoot summary is to simplify coding, configuration, deployment, monitoring, and so on.

5. Which is the core comment of Spring Boot? What are the main annotations it consists of?

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

@ SpringBootConfifiguration: combines @ Confifiguration annotations to implement the function of configuration files.

@ EnableAutoConfifiguration: enable the auto-configuration feature, or disable an auto-configuration option, for example: java: turn off the data source auto-configuration feature: @ SpringBootApplication (exclude = {DataSourceAutoConfiguration.class}).

@ ComponentScan:Spring component scan.

6. What logging frameworks does Spring Boot support? Which is the recommended or default logging framework?

Spring Boot supports Java Util Logging, Log4j2, Lockback as the logging framework, if you use Starters initiator, Spring Boot will use Logback as the default logging framework, but no matter which kind of logging framework it supports the output of configuration files to the console or file.

7. How SpringBoot Starter works

I personally understand that SpringBoot is composed of all kinds of Starter, and we can also develop Starter ourselves.

When sprinBoot starts, the @ SpringBootApplication annotation automatically reads the spring.factories file in each starter in maven, which configures all the bean in the spring container that needs to be created, and automatically configures bean injection into SpringContext / / (SpringContext is the configuration file of Spring)

8. What are the new features of Spring Boot 2.x? What's the difference between 1.X and 1.x?

Configuration change

JDK version upgrade

Third-party class library upgrade

Responsive Spring programming support

HTTP/2 support

Configure property binding

More improvement and strengthening

9. What front-end templates are supported by SpringBoot

Thymeleaf,freemarker,jsp, JSP is not officially recommended. There will be restrictions.

10. Shortcomings of SpringBoot

I think it's embarrassing. At present, I don't think SpringBoot has any shortcomings. I think it is necessary to find one.

Because you don't have to make your own configuration, it's hard to locate when you report an error.

11. What are the ways to run Spring Boot?

Package with commands or run in a container

Run with the Maven/ Gradle plug-in

Directly execute the main method to run

12. Does Spring Boot need to be run in a separate container?

Can not be needed, built-in containers such as Tomcat/ Jetty.

13. What are the ways to turn on the Spring Boot feature?

Inherit spring-boot-starter-parent project

Import spring-boot-dependencies project dependencies

14. What are the ways for SpringBoot to achieve hot deployment?

15. Use of SpringBoot things

The SpringBoot thing is very simple, first use the annotation EnableTransactionManagement to open the thing, and then add the annotation Transactional to the Service method.

16. Async asynchronous invocation method

Using asynchronous calls in SpringBoot is simple, and you only need to use the @ Async annotation on the method to implement the asynchronous call to the method. Note: you need to add @ EnableAsync to the startup class to make the asynchronous call @ Async annotation effective.

17. 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, and both provide only one run method

18. What are the ways for Spring Boot to read configurations?

Spring Boot can bind variables through @ PropertySource,@Value,@Environment, @ ConfifigurationPropertie annotations

19. What is JavaConfig?

20. What is the principle of automatic configuration of SpringBoot

21. How do you understand the loading sequence of Spring Boot configuration?

twenty-two。 What is YAML?

YAML is a human-readable data serialization language. It is usually used for configuration files. If we want to add complex properties to the configuration file, the YAML file is more structured and less confusing than the properties file. You can see that YAML has hierarchical configuration data.

23. What are the advantages of YAML configuration?

24. Can Spring Boot be configured using XML?

Spring Boot recommends using Java configuration instead of XML configuration, but XML configuration can also be used in Spring Boot, and a XML configuration can be introduced through the @ ImportResource annotation.

25. What is the spring boot core profile? What is the difference between bootstrap.properties and application.properties?

twenty-six。 What is Spring Profiles?

twenty-seven。 The idea of splitting multiple data sources in SpringBoot

First configure two data sources in the properties configuration file, create a subcontract mapper, use @ ConfifigurationProperties to read the configuration in properties, and use @ MapperScan to register in the corresponding mapper package

twenty-eight。 How to manage SpringBoot Multi-data Source transactions

The first way is to use transactionManager in @ TransactionManager of the service layer to specify the transaction configured in DataSourceConfifig.

The second is to use jta-atomikos to implement distributed transaction management.

twenty-nine。 What are the ways to protect Spring Boot applications?

Using HTTPS in production

Use Snyk to check your dependencies

Upgrade to the latest version

Enable CSRF protection

Use content security policies to prevent XSS attacks

thirty。 How to implement the security of Spring Boot applications?

thirty-one。 Compare the advantages and disadvantages of Spring Security and Shiro?

thirty-two。 How to solve the cross-domain problem in Spring Boot?

Cross-domain can be solved through JSONP at the front end, but JSONP can only send GET requests, but cannot send other types of requests. In RESTful-style applications, it is very fishy, so we recommend (CORS,Crossorigin resource sharing) to solve cross-domain problems at the back end. This kind of solution is not specific to Spring Boot. In the traditional SSM framework, we can solve the cross-domain problem through CORS, but before we configured CORS in the XML file, now we can solve the cross-domain problem by implementing the WebMvcConfifigurer interface and then rewriting the addCorsMappings method.

@ Configurationpublic class CorsConfig implements WebMvcConfigurer {@ Override public void addCorsMappings (CorsRegistry registry) {registry.addMapping ("/ *") .allowedOrigins ("*") .allowCredentials (true) .allowedMethods ("GET", "POST", "PUT", "DELETE", "OPTIONS") .maxAge (3600);}} 33. What is the monitor in Spring Boot?

thirty-four。 How to use Spring Boot to implement global exception handling?

Spring provides a very useful way to handle exceptions using ControllerAdvice. We handle all the exceptions thrown by the controller class by implementing a ControlerAdvice class.

thirty-five。 How do we monitor all Spring Boot microservices?

thirty-six。 How to optimize the performance of SpringBoot

If the project is large and there are many classes, instead of using @ SpringBootApplication, use @ Compoment to specify the scope of the package sweep.

Set JVM initial memory and maximum memory the same at the start of the project

Set the springboot built-in server from tomcat to undertow

thirty-seven。 How do I reload changes on Spring Boot without restarting the server? How is the Spring Boot project hot to deploy?

thirty-eight。 How to implement session sharing in SpringBoot micro-services?

thirty-nine。 Which starter maven dependencies do you use?

forty。 What exactly is starter in Spring Boot?

forty-one。 How to implement scheduled tasks in Spring Boot?

There are two main ways to use timed tasks in Spring Boot, one is to use the @ Scheduled annotation in Spring, and the other is to use the third-party framework Quartz.

The use of @ Scheduled in Spring is mainly achieved through the @ Scheduled annotation.

forty-two。 What's the use of spring-boot-starter-parent?

forty-three。 How to implement Packaging in SpringBoot

Enter the project directory and enter mvn clean package,clean in the console to empty the existing project package and package it with package.

Or click Mavne in the left option bar, click clean first, and then click package

What is the difference between a 44.Spring Boot jar and an ordinary jar?

forty-five。 What are the characteristics of SpringBoot?

Create a stand-alone Spring application

Directly embed Tomcat,Jetty or Undertow (no need to deploy WAR files)

Provide solidified "starter" dependencies to simplify build configuration

Automatically configure Spring and 3rd Party libraries as much as possible

Provide features that can be used for production, such as metrics, health checks, and externalized configuration

There is no code generation at all and no XML configuration is required

forty-six。 How to quickly build a SpringBoot project?

Use it through the Web interface. Http://start.spring.io

Used through Spring Tool Suite.

Used through IntelliJ IDEA.

Use Spring Boot CLI to use.

47.SpringBoot startup class comments? What annotations does it consist of?

forty-eight。 What is yaml?

YAML (/ camel camel) is a highly readable format used to express data serialization. YAML refers to a variety of other languages, including: C, Python, Perl. More structural.

What is the format of configuration files supported by 49.SpringBoot?

How to start 50.SpringBoot?

Main method

Command line java-jar mode

Mvn/gradle

Does 51.SpringBoot need to be run in a separate container?

No, Tomcat/Jetty is built in.

52.SpringBoot configuration path?

Command line argument

JNDI attribute in java:comp/env

JVM system Properties

Operating system environment variable

Randomly generated properties with random.* prefixes (you can reference them when setting other properties, such as ${random.long})

Application.properties or appliaction.yml files other than the application

Application.properties or appliaction.yml files packaged in the application

Attribute sources annotated through @ PropertySource

Default attribute

Where can 53.application.properties and application.yml files be placed? Priority?

The principle of 54.SpringBoot automatic configuration?

@ EnableAutoConfifiguration (enable automatic configuration) this annotation introduces AutoConfifigurationImportSelector, and the method in this class scans all jar packages that contain META-INF/spring.factories.

55.SpringBoot hot deployment mode?

Spring-boot-devtools

Spring Loaded

Jrebel

Hot deployment of templates

56. "bootstrap.yml" and "application.yml"?

Bootstrap.yml takes precedence over application.yml

How does 57.SpringBoot change the port number?

fifty-eight。 How many ways to turn on SpringBoot features?

Inherit spring-boot-starter-parent project

Import spring-boot-dependencies project dependencies

How is 59.SpringBoot compatible with Spring projects?

In the startup class, add:

@ ImportResource (locations = {"classpath:spring.xml"})

60.SpringBoot configuration monitoring? org.springframework.bootspring-boot-starter-actuator61. Which endpoint is accessed for Bean assembly report information?

/ beans endpoint

sixty-two。 Which endpoint is accessed by closing the application?

sixty-three。 Which endpoint is accessed to view the published application information?

/ info

sixty-four。 How many combined comments for the request for access?

@ PatchMapping

@ PostMapping

@ GetMapping

@ PutMapping

@ DeleteMapping

Starter in 65.SpringBoot?

66.SpringBoot integrates Mybatis?67. What is SpringProfiles?

Mybatis-spring-boot-starter

sixty-eight。 Configuration files for different environments?

sixty-nine。 How do I activate the configuration of an environment?

seventy。 Write notes for test cases?

@ SpringBootTest

Notes related to 71.SpringBoot exception handling?

@ ControllerAdvice

@ ExceptionHandler

The difference between 72.SpringBoot 1.x and 2.x?

SpringBoot 2 is based on Spring5 and JDK8,Spring 1x with a lower version.

Configuration changes, parameter names, etc.

Many of the minimum versions of SpringBoot2-related plug-ins are higher than the original.

2.x the Chinese in the configuration can be read directly without transcoding

Changes in Actuator

Changes in CacheManager

What are the notes related to the 73.SpringBoot read configuration?

@ PropertySource

@ Value

@ Environment

@ ConfifigurationProperties

At this point, the study on "what are the interview questions for the latest version of Spring Boot in 2021" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report