preface

Today, as a Coder of the most mainstream language Java, it is very important to master Spring Boot correctly, systematically and quickly. Next, let’s walk into the world of Spring Boot and feel the charm of Spring Boot together. I firmly believe that opportunities always belong to those who are well prepared. Instead of envying others’ success, we should accumulate enough knowledge and interview experience from now on to make full preparation for entering a better company in the future.

Want to impress your interviewer in a few minutes? Want to harvest the core knowledge of the Java technology stack in the shortest possible time? Want a more comprehensive and in-depth understanding of Java technology? This article gives you all the answers you need.

JavaOOP, Java collection container, Java Exceptions, concurrent programming, Java reflection, Java serialization, JVM, Redis, Spring MVC, MyBatis, MySQL database, message middleware MQ, Dubbo, Linux, ZooKeeper, distributed & data structure and algorithm and other 25 special technical points, are xiaobian in each big factory summed up the interview question, there are a lot of fans rely on this PDF to win many big factory offer, Today, I am here to summarize and share with you! 【 Finished 】

Full version of Java interview questions address: 2021 latest interview questions collection collection.

The serial number project content link
1 The middleware Java Middleware Interview Questions (Latest version 2021) Juejin. Cn/post / 694870…
2 Micro service Java Micro Service Test Questions (updated version 2021) Juejin. Cn/post / 694906…
3 Concurrent programming Java Concurrent Programming Interview Questions (Updated 2021) Juejin. Cn/post / 695053…
4 Java based Java Basics Test Questions (2021 latest edition) Juejin. Cn/post / 695062…
5 Spring Boot Spring Boot Interview Questions (Updated 2021) Juejin. Cn/post / 695137…
6 Redis Redis Interview Questions (Updated 2021) Juejin. Cn/post / 695166…
7 Spring MVC Spring MVC Interview Questions (updated 2021) Juejin. Cn/post / 695166…
8 Spring Cloud Spring Cloud Interview Questions (Updated 2021) Juejin. Cn/post / 695245…
9 MySQL optimization MySQL optimized Interview Questions (2021 update) Juejin. Cn/post / 695246…
10 JVM JVM Performance Tuning Interview Questions (Latest version 2021) Juejin. Cn/post / 695246…
11 Linux Linux Interview Questions (Latest edition, 2021) Juejin. Cn/post / 695287…
12 Mybatis Mybatis Interview Questions (latest version 2021) Juejin. Cn/post / 695287…
13 Network programming TCP, UDP, Socket, Http Network Programming Juejin. Cn/post / 695287…
14 Design patterns Design Mode Interview Questions (latest version 2021) Juejin. Cn/post / 695544…
15 Big data 100 Big Data Interview Questions (the latest version of 2021) Juejin. Cn/post / 695544…
16 Tomcat Tomcat Interview Questions (latest version 2021) Juejin. Cn/post / 695570…
17 multithreading Multi-threaded Interview Questions (Latest edition 2021) Juejin. Cn/editor/draf…
18 Nginx Nginx_BIO_NIO_AIO Interview Questions (Updated 2021) Juejin. Cn/editor/draf…
19 memcache Memcache Interview Questions (Updated 2021) Juejin. Cn/post / 695608…
20 Java exception Java Exception Interview Questions (latest edition, 2021) Juejin. Cn/post / 695644…
21 The Java virtual machine Java Virtual Machine Interview Questions (Latest version 2021) Juejin. Cn/post / 695658…
22 Java collection Java Collection Interview Questions (Latest edition 2021) Juejin. Cn/post / 695684…
23 Git Common Commands Git Common Commands (updated 2021) Juejin. Cn/post / 695692…
24 Elasticsearch Elasticsearch Interview Questions (Updated 2021) Juejin. Cn/post / 695840…
25 Dubbo Dubbo Interview Questions (Latest edition 2021) Juejin. Cn/post / 695842…

What is SpringBoot?

With Spring Boot, you can easily create standalone, production-level Spring-based applications that you can “run.” Most Spring Boot applications require minimal Spring configuration.

2. Why SpringBoot

Rapid development, rapid integration, simple configuration, embedded service container

3. Differences between SpringBoot and SpringCloud

SpringBoot is a Spring framework for rapid development, while SpringCloud is a complete microservice framework. SpringCloud depends on SpringBoot.

4. What are the advantages of Spring Boot?

Spring Boot has the following advantages:

  1. Easy to get started, improve development efficiency, Spring development to provide a faster, simpler development framework.
  2. Out of the box, away from cumbersome configurations.
  3. Provides a range of non-business functions common to large projects, such as embedded servers, security management, monitoring of operational data, health checks, and externalized configuration.
  4. SpringBoot concludes with simple coding, simple configuration, simple deployment, simple monitoring, and so on

5. What are the core annotations of Spring Boot? What annotations is it made up of?

The @springBootApplication annotation is the core annotation of SpringBoot. It consists of the following three annotations:

  • @ SpringBootConfifiguration: combination of @ Confifiguration annotations, realize the function of the configuration file.
  • @ EnableAutoConfifiguration: open the function of automatic configuration, also can turn off some automatic configuration options, cases such as Java, such as closed source automatic configuration function: @ SpringBootApplication (exclude = {DataSourceAutoConfiguration. Class}).
  • @componentscan: Spring ComponentScan.

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

Spring Boot supports Java Util Logging, Log4j2, and Lockback as Logging frameworks. If you use the Starters, Spring Boot will use Logback as the default Logging framework. However, both logging frameworks support output of configuration files to the console or to a file.

7. How the SpringBoot Starter works

  • I personally understand that SpringBoot is a combination of different kinds of Starter, we can also develop our own Starter
  • When sprinBoot starts, the @springBootApplication annotation automatically reads the spring.factories file in each Maven starter, which configures all the beans that need to be created in the Spring container. // (SpringContext is the Spring configuration file)

8. What’s new with Spring Boot 2.X? What’s the difference between 1.x and 1.x?

  • Configuration changes
  • Upgrading the JDK version
  • Third party class library upgrade
  • Responsive Spring programming support
  • Support HTTP / 2
  • Configuring Property Binding
  • More improvements and enhancements

What front-end templates does SpringBoot support?

Thymeleaf, Freemarker, JSP, official not recommended JSP will be limited

10. Disadvantages of SpringBoot

  • I think it’s a dilemma. At present, I don’t think SpringBoot has any shortcomings
  • Because you do not have to do their own configuration, error is difficult to locate.

11. What are the ways to run Spring Boot?

    1. Packaging is run as a command or in a container
    1. Run with Maven/ Gradle plugin
    1. Execute the main method directly

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

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

13. What are the ways to enable Spring Boot?

  1. Inherits the spring-boot-starter-parent project
  2. Import the spring-boot-Dependencies project dependencies

14. How many ways can SpringBoot implement hot deployment?

15. Use of SpringBoot things

  • SpringBoot things is very simple, the first to use annotations EnableTransactionManagement open after things, and then add annotations Transactional can be on the Service method.

16. Async Calls methods asynchronously

  • Using asynchronous calls in SpringBoot is as simple as using the @async annotation on a method. Note: You need to add @enableAsync to the startup class for the @async annotation to take effect.

17. How to run certain 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

18. How many ways can Spring Boot read configuration?

  • Spring Boot can bind variables with the @propertysource, @value, @environment, and @ConfiFigurationPropertie annotations

19. What is JavaConfig?

20. How does SpringBoot automate configuration work

21. How do you understand the Spring Boot configuration load order?

22. What is YAML?

  • YAML is a human-readable data serialization language. It is usually used for configuration files. YAML files are more structured and less confusing than properties files if we want to add complex properties to configuration files. As you can see, YAML has layered configuration data.

23. What are the advantages of YAML configuration?

24. Can Spring Boot be configured using XML?

  • Spring Boot recommends Java configuration over XML configuration, but XML configuration can also be used in Spring Boot, and an XML configuration can be imported through the @ImportResource annotation.

What is the Spring Boot core configuration file? What is the difference between bootstrap.properties and application.properties?

26. What is Spring Profiles?

27. Splitting SpringBoot multiple data sources

  • First in the properties in the configuration file to configure two data sources, to create the subcontract mapper, using the @ ConfifigurationProperties read the properties of configuration, use the @ MapperScan registered to the corresponding mapper package

28. How are SpringBoot multi-data source transactions managed

  • The first is to specify the transactions configured in DataSourceConfifig using TransactionManager in @TransactionManager at the Service layer
  • The second is to implement distributed transaction management using JTA-Atomikos

29. What are some ways to protect A Spring Boot application?

  • Use HTTPS in production
  • Use Snyk to check your dependencies
  • Upgrade to the latest version
  • The CSRF protection is enabled
  • Use content security policies to prevent XSS attacks

30. How do I secure a Spring Boot application?

31. What are the advantages and disadvantages of Spring Security and Shiro?

32. How do I solve cross-domain problems in Spring Boot?

  • Cross-domain can be solved on the front end with JSONP, but JSONP can only send GET requests, not other types of requests, in RESTful applications, it is very weak, so we recommend using (CORS, Crossorigin Resource Sharing) to address cross-domain issues. This solution is not specific to Spring Boot. In a traditional SSM framework, you can solve cross-domain problems with CORS, but previously we configured CORS in an XML file. Now you can solve the cross-domain problem by implementing the WebMvcConfifigurer interface and then overwriting the addCorsMappings method.
@Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowCredentials(true) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") .maxAge(3600); }}Copy the code

33. What are the monitors in Spring Boot?

34. How do I use Spring Boot to handle global exceptions?

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

35. How do we monitor all Spring Boot microservices?

36. How can I optimize SpringBoot performance

  • If the project is large and has many analogies, instead of using @springBootApplication, use @compoment to specify the sweep scope
  • Set the JVM initial memory to be the same as the maximum memory at project startup
  • Set the SpringBoot built-in server by Tomcat to undertow

37. How do I reload changes in Spring Boot without having to restart the server? How can a Spring Boot project be hot-deployed?

38. How to implement session sharing in SpringBoot microservice?

39. Which Starter Maven dependencies do you use?

40. What is a starter in Spring Boot?

41. How do I implement scheduled tasks in Spring Boot?

  • There are two different ways to use Scheduled 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 @Scheduled approach in Spring is implemented primarily through the @Scheduled annotation.

42. What’s the use of spring-boot-starter parent?

43. How does SpringBoot implement packaging

  • Go to the project directory and type MVN Clean Package in the console. Clean is to empty the existing project packages and package is to package
  • Or click Mavne in the left sidebar, click Clean first and then click Package

44. What is the difference between a Spring Boot typed JAR and a regular JAR?

45. Features of SpringBoot?

  • Create a stand-alone Spring application
  • Embed Tomcat, Jetty, or Undertow directly (no need to deploy WAR files)
  • Provide solidified “starter” dependencies to simplify build configurations
  • Automatically configure the Spring and 3rd Party libraries whenever possible
  • Provides production-ready functionality, such as metrics, health checks, and externalization configurations
  • No code generation at all and no XML configuration is required

46. How to quickly build a SpringBoot project?

  • Use the Web interface. start.spring.io
  • Using the Spring Tool Suite.
  • Used through IntelliJ IDEA.
  • Use the Spring Boot CLI.

47.SpringBoot Boot class annotations? What annotations does it consist of?

48. What is YAML?

  • YAML (/ˈjæməl/) is a readable format for data serialization. YAML references a number of other languages, including C, Python, and Perl. It’s more structured.

49. What format does SpringBoot support for configuration files?

50.SpringBoot boot mode?

    1. The main method
    1. Java-jar command line
    1. mvn/gradle

51. Does SpringBoot need a separate container to run?

  • No, Tomcat/Jetty is built in.

52. How to configure SpringBoot?

  1. Command line arguments
  2. Java: JNDI properties in comp/env
  3. JVM system properties
  4. Operating system environment variables
  5. Randomly generated properties prefixed by random.* (you can refer to them when setting other properties, such as ${random.long})
  6. Application. Properties or appliaction.yml files outside the application
  7. The application.properties or appliaction.yml file packaged within the application
  8. The PropertySource annotated via @propertysource
  9. The default attribute

53. Application. The properties and application. The yml file location can be put on? Priority?

54. How does SpringBoot automate configuration work?

@ EnableAutoConfifiguration automatic configuration (open) the annotations introduced AutoConfifigurationImportSelector, methods of this class will scan all exist the meta-inf/spring. Factories jars.

55.SpringBoot hot deployment mode?

  • spring-boot-devtools
  • Spring Loaded
  • Jrebel
  • Template hot deployment

56. “bootstrap.yml” and “Application. yml”?

  • Bootstrap. yml takes precedence over application.yml

57. How can SpringBoot change the port number?

58. How can I enable the SpringBoot feature?

  1. Inherits the spring-boot-starter-parent project
  2. Import the spring-boot-Dependencies project dependencies

59. How does SpringBoot work with Spring projects?

In the startup class add:

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

60.SpringBoot configuration monitoring?

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Copy the code

61. Which endpoint is accessed to obtain Bean assembly report information?

  • / beans endpoint

62. Which endpoint does the closing application access?

63. Which endpoint is accessed to view published application information?

  • /info

64. How many combined annotations for requested access?

  • @PatchMapping
  • @PostMapping
  • @GetMapping
  • @PutMapping
  • @DeleteMapping

65. Starter in SpringBoot?

66. Mybatis SpringBoot integration?

67. What is SpringProfiles?

mybatis-spring-boot-starter

68. Configuration files for different environments?

69. How do I enable the configuration of an environment?

Write test case annotations?

  • @SpringBootTest

71. Comments on SpringBoot Exception handling?

  • @ControllerAdvice
  • @ExceptionHandler

72. What is the difference between SpringBoot 1.x and 2.x?

  1. SpringBoot 2 is based on Spring5 and JDK8, while Spring 1X uses an earlier version.
  2. Configuration changes, parameter names, etc.
  3. Many of the earliest versions of the plugins associated with SpringBoot2 are higher than the original
  4. 2. The Chinese characters in the X configuration can be read directly without transcoding
  5. The change of the physical
  6. The change of the CacheManager

73. Is there any comment related to SpringBoot read configuration?

  • @PropertySource
  • @Value
  • @Environment
  • @ConfifigurationProperties

Spring Boot interview questions 【 解析】

The last

Xiaobian to share the article here is the end, sorting is not easy, welcome to communicate with you, like xiaobian to share the article remember to pay attention to me like yo, thank you for your support!