Summary of Java Classic Interview Questions: Spring Boot

  • 2021-11-02 00:46:23
  • OfStack

Directory 1. What is Spring Boot? 2. Why use Spring Boot? 3. What is the Spring Boot core configuration file? 4. What common Starter Project Options does Spring Boot offer? 5. How to quickly build an Spring Boot project? 6. What is the default built-in Web server for Spring Boot? 7. Common annotations of Spring Boot and their functions? 8. How can I configure a specific environment through Spring Boot using a configuration file? Summarize

1. What is Spring Boot?

Spring Boot serves Spring and is designed to simplify the initial build and development process of the new Spring application.

2. Why use Spring Boot?

Simple configuration Independent operation Automatic assembly No code generation and xml configuration Provide application monitoring Easy to use Improve development efficiency

3. What is the Spring Boot core configuration file?

Two configuration files of spring boot core: bootstrap (. yml or. properties): boostrap is loaded by parent ApplicationContext, which takes precedence over applicaton, and the attributes in boostrap cannot be overwritten; application (. yml or. properties): Used for automated configuration of the spring boot project.

4. What common Starter Project Options are available from Spring Boot?

spring-boot-starter: Core starter, including automated configuration support, logging, and YAMLspring-boot-starter-aop: Section programming related to Spring, AOP and AspectJ starterspring-boot-starter-data-jpa: starterrspring-boot-starter-jdbc using Hibernate Spring Data JPA: starter using HikariCP connection pool JDBC spring-boot-starter-security: starter with Spring Security spring-boot-starter-test: SpringBoot Test Related starter spring-boot-starter-web: starter for building web applications for restful, springMVC

5. How to quickly build an Spring Boot project?

Spring-initializr

Aliyun Java initializr

6. What is the default built-in Web server for Spring Boot?

Tomcat

7. Spring Boot Commonly used Annotations and Their Functions?

@ SpringBootApplication: This annotation is the core annotation of Spring Boot, which is used on the main class of Spring Boot, identifying that this is an Spring Boot application, which is used to open various capabilities of Spring Boot. In fact, this annotation is a combination of @ Configuration, @ EnableAutoConfiguration and @ ComponentScan. Since these annotations 1 are generally used once, Spring Boot provides a annotation @ SpringBootApplication. @ EnableAutoConfiguration: Allows Spring Boot to automatically configure annotations. When this annotation is turned on, Spring Boot can configure Spring Bean according to the package or class under the current classpath. @ ConfigurationProperties: This allows you to convert properties from properties or yml configurations directly to objects (read properties from yml/properties standard configuration file for springboot and assign them to objects @ EnableConfigurationProperties: Classes that use annotations to @ ConfigurationProperties take effect. @ SpringBootConfiguration: Inherited from @ Configuration, both have the same function, label the current class as a configuration class, and bring one or more instances of methods declared in the current class marked with @ Bean annotation into the spring container, and the instance name is the method name.

8. How can I configure a specific environment through Spring Boot using a configuration file?

In the application. properties configuration file, add: spring. profiles. active = dev, and add the application-dev. properties file, add application-prod. properties for multiple environments, and so on, and modify the corresponding value for active.

Summarize

This article is here, I hope to give you help, but also hope that you can pay more attention to this site more content!


Related articles: