Spring ten questions Boot interview

With these common interview questions below for the next Spring Boot interview preparation.

In this article, we will discuss Spring boot of the 10 most common interview questions. Now, in the job market, these problems are a bit tricky, and the trend is getting worse.

1. @SpringBootApplication is doing what?

According to Spring Boot document, @SpringBootApplication annotation is equivalent to using @Configuration, @ EnableAutoConfiguration and @ComponentScan its default properties. Spring Boot allows developers to use a single annotation instead of multiple notes. But, as we know, Spring provides loose coupling characteristics, we can use each comment individually according to needs of the project.

2. How to exclude any package without the use of basePackages filters?

You can filter any packets in different ways. However, without contact assembly scans, Spring Boot for the realization of this provides a sophisticated option. When you use annotations @SpringApplication, you can use the excludeproperty. Refer to the following code fragment:

@SpringBootApplication(exclude= {Employee.class})public class FooAppConfiguration {}

3. How to disable a particular auto-configuration class?

If you do not want to automatically configure a particular class effect, you can use @EnableAutoConfigurationthe excludeproperty.

//By using "exclude"@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

On the other hand, if the class is not in the class path, you can use the annotation excludeNameproperty and specify the fully qualified name.

//By using "excludeName"@EnableAutoConfiguration(excludeName={Foo.class})

Further, Spring Boot by using spring.autoconfigure.excludefor the automatic control means arranged to exclude the attribute class list. You can add to the application.properties. And you can add multiple categories separated by commas.

//By using property filespring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

4. What is the Spring Actuator? What are its strengths?

Spring Boot This is one of the most common interview questions. Spring according to the document:

"Actuator manufacture is a term that refers to a mechanical device for moving or controlling something .Actuator may be produced by a large number of small changes in motion."

As we know, Spring Boot provides many auto-configuration features to help developers quickly develop product components. However, if you consider how commissioning and commissioning, if what the problem is, we always need to analyze the logs and flow data mining application to check what happened. Therefore, Spring Actuator provides easy access to these types of functions. It offers many features, such as creating what the bean, the controller mapping, CPU usage, and so on. Then automatically collect and audit the health status (health) and indicators (metric) can be to your application.

It provides a very easy way to access the REST endpoint few production-ready and get all kinds of information from the Web. But by using these endpoints, you can do a lot to see the document endpoint. Without worrying about security; if there is Spring Security, then use content negotiation strategies Spring Security in case of default to protect these endpoints. Or, we can RequestMatcherhelp to configure a custom security.

5. How to enable / disable Actuator?

Enable / disable Actuator is very simple. The easiest way is to enable the feature, add a dependency (Maven / Gradle) to Spring-Boot-Starter-Actuator , i.e., Starter. If you do not want Actuator start, not added dependency.

Maven relies:

<dependencies>  <dependency>        <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-actuator</artifactId>   </dependency></dependencies>

6. What is the Spring Initializer?

This may not be a difficult problem, but the interviewer will always check the candidate's expertise. Usually you can not always expect that you have prepared questions. However, this is almost always a very common problem.

Spring Initializer is a Web application that uses everything needed to quickly start to generate Spring start the project. As usual, we need a good project framework; it can help you to correctly create the project structure / framework. Here you can learn more about the initializer.

Close 7. Actuator what is?

Close is an endpoint, which allows applications to gracefully shut down. This feature is not enabled by default. You can use the file in an application by application.properties in management.endpoint.shutdown.enabled = true to enable this feature. But if you use this, then be careful.

8. embedded Tomcat server can change the port do in Spring boot in?

Yes, you can change the port. You can use application.properties file to change the port. But the need to mention " server.port " (ie: server.port = 8081 ). Application.properties ensure project classpath; REST Spring framework will handle the rest. If you mention server.port = 0 , then it will automatically assign any available port.

9. We can override or replace the embedded Tomcat server in Spring Boot in it?

Yes, we can use the Starter dependencies embedded Tomcat replaced by any other server. You can use as needed spring-boot-starter-jettyor spring-boot-start -undertowas dependencies for each item.

10. We can disable the default web server in Spring Boot application do?

The main advantage of Spring is to provide flexibility to build loosely coupled applications. Spring provides disabled Web server in the quick configuration function. Yes, we can use application.properties to configure your web application types, namely: spring.main.web-application-type=none.

wish all the best!

Source: http://www.spring4all.com/article/15119

Recommended reading:

"In-depth understanding of the Java Memory Model" study notes

Interview - The Basics

Spring Boot 2.0 Migration Guide

SpringBoot use Docker rapid deployment project

Part I good text:

Why did you choose as the Spring Java framework?

Button in the upper right corner to share with more people oh ~ **imgimg **

img

Guess you like

Origin blog.51cto.com/14437304/2424124