In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the common Spring Boot interview questions". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what are the common Spring Boot interview questions" together!
1. What is the use of @SpringBootApplication comments internally?
As Spring boot documentation, the @SpringBootApplication annotation is equivalent to using @Configuration,@EnableAutoConfiguration, and @ComponentScan together with their default properties. Spring Boot allows developers to work with a single comment rather than multiple comments. However, Spring is known to provide loosely-coupled features that we can use for each annotation depending on the project needs.
2. How do I exclude packages without using BasePACKAGE filter?
Different ways to filter packages. But spring activation offers a more sophisticated option that can be achieved without touching the component scan. When using the annotation @ SpringBootApplication, you can use the exclusion attribute. See the following code snippet:
@SpringBootApplication(exclude= {Employee.class}) public class FooAppConfiguration {}
3. How do I disable certain autoconfiguration classes?
If you find any particular autoconfiguration classes you don't want to use, you can use the exclusion property of @EnableAutoConfiguration.
//By using "exclude" @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
On the other hand, if the category is not on the classpath, you can use the excludeName class annotation and specify a fully qualified name.
//By using "excludeName" @EnableAutoConfiguration(excludeName={Foo.class})
In addition, Spring Boot has the ability to control the list of excluded autoconfiguration classes, which can be achieved by using spring. autofigure.exclude property. It can be added to a propertie application, and multiple classes separated by commas can be added.
//By using property file spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
4. What is Spring Actuator? What are its advantages?
This is one of the most common interview questions in Spring Boot. According to Spring File:
An actuator is a manufacturing term that refers to a mechanical device that moves or controls something. Actuators can produce a large number of movements from a small change.
Spring Boot is known to provide many automatic configuration features that help developers quickly develop production components. But when you think about debugging and how to debug, if something goes wrong, you always need to analyze the logs and mine the data flow of the application to see where the problem is. Therefore, Spring Actuator provides easy access to these types. It provides many characteristics, such as what beans are created, mappings in the controller, CPU usage, and so on. It can also apply automated collection and auditing of health and metrics to applications.
It provides a very simple way to access a small number of production-ready REST endpoints and get all kinds of information from the Web. But by using these endpoints, you can do a lot to view endpoint documents. There is no need to worry about security; if Spring Security exists, these endpoints are protected by default using Spring Security's content negotiation policy. Alternatively, you can configure custom security with the help of RequestMatcher.
5. How do I enable/disable actuators?
Enabling/disabling an actuator is easy; the easiest way is to enable the feature to add dependencies (Maven/Gradle) to the spring-boot-starter-actuator, or launcher. If you don't want to enable actuators, don't add dependencies.
Maven dependencies:
org.springframework.boot spring-boot-starter-actuator
6. What is Spring Initializer?
This question isn't difficult, but interviewers always use it to test a candidate's expertise.
Spring Initializer is a web application that generates a Spring Boot project that contains everything you need to get started quickly. As always, we need a good project framework; it helps you create the project structure/framework correctly.
7. What is actuator shutdown?
Shutdown is an endpoint that allows an application to shut down normally. By default, this feature is not enabled. You can use management in your application properties file. endpoint . shut down . enabled = true to enable this option. But this method should be used with caution.
8. Can I change the port of the embedded Tomcat server in Spring boot?
Yes, changing ports is possible. You can change ports using the application.properties file. But you need to mention "server.port"(i.e. server.port=8081). Make sure that application.properties is in the project classpath; the rest will be taken over by the REST Spring Framework. If server.port=0 is mentioned, it will automatically assign any available port.
9. Can embedded Tomcat be overridden or replaced in Spring Boot?
Yes, embedded Tomcat can be replaced with any other server using the starter dependency. You can use SpringBootStarter Jetty or SpringBootStarter as a dependency for each project as desired.
10. Can I disable the default Web server in a Spring Boot application?
Spring's main advantage is the flexibility it provides to build loosely coupled applications. Spring provides the ability to disable web servers in quick configuration. You can configure network application types using application properties, such as spring.main.web-application-type=none.
Thank you for reading, the above is the content of "What are the common Spring Boot interview questions?" After studying this article, I believe that everyone has a deeper understanding of the common Spring Boot interview questions, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.