Internet giant interview will ask questions face 22 spring Boot

Question one

What is Spring Boot?

Over the years, with the increase of new features, spring becomes more and more complex. Just visit https://spring.io/projects page, we'll see different functions all Spring projects can be used in our application. If you must start a new Spring project, we must add the build path or add Maven dependencies, configure the application server, add the spring configuration. So start a new spring project requires a lot of effort because we must now do everything from scratch.

Spring Boot is a solution to this problem. Spring Boot has been built on top of an existing spring frame. Using spring starts, we avoided all the boilerplate code and configuration before we have to do. Therefore, Spring Boot can help us with the least amount of work, more robust use of existing Spring function.

Question two

What are the advantages Spring Boot there? 

Spring Boot advantages are:

1, reducing development, testing time and effort.

2, JavaConfig helps to avoid the use of XML.

3, to avoid a large number of import and Maven versions conflict.

4, method development advice.

5, began developing quickly by providing default values.

6, there is no need for a separate Web server. This means that you no longer need to start Tomcat, Glassfish or anything else.

7, because there is no need less configuration file web.xml. Just add the class with annotation @ Configuration, and then add comment @Bean method, Spring will automatically load the object and as before to manage it. You can even add @Autowired to bean methods, so Spring dependencies automatically loaded in need.

8, the use of these attributes based configuration environment, you can pass into the environment you are using applications: -Dspring.profiles.active = {enviornment}. After loading the main application attribute file, Spring will (application {environment} .properties) subsequent files to load application properties.

Question three

What is JavaConfig? 

Spring JavaConfig Spring community is the product that provides a way to configure a pure Java Spring IoC container. So it helps to avoid the use of XML configuration. The advantage of using JavaConfig in that:

1, object-oriented configuration. Since configuration is defined as JavaConfig classes, the user can take advantage of Java is the object-oriented features. A class can inherit another configuration, a method of rewriting its @Bean.

2, to reduce or eliminate XML configuration. Additional benefits of dependency injection principles based configuration has been demonstrated. However, many developers do not want to switch back and forth between XML and Java. JavaConfig provides a pure Java method for developers to configure the XML configuration similar to the concept of the Spring container. From a technical point of view, only JavaConfig configuration class to configure the container is feasible, but in fact a lot of people think that XML will JavaConfig and mix and match is ideal.

3, the type of security and reconstruction friendly. JavaConfig provides a type-safe way to configure Spring container. Because Java 5.0 support for generics, can now be retrieved by type rather than by name bean, without any coercion or based on a search string.

Question four

How to reload changes on Spring Boot, without restarting the server? 

You can use this tool to achieve DEV. In this dependency, you can save any changes, embedded tomcat restarts. Spring Boot there is a development tool (DevTools) module, which helps improve developer productivity. A major challenge faced by Java developers that will change automatically deployed to the server and automatically restart the server files. Developers can reload Spring changes on the Boot, without restarting the server. This will eliminate the need to manually deploy each time change. Spring Boot Without this function when it released the first version. This is the developer of the most needed function. DevTools modules fully meet the needs of developers. The module will be disabled in a production environment. It also provides console H2 database to better test the application.

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-devtools</artifactId>

<optional>true</optional>

</dependency>

Five questions

What in the Spring Boot Monitor is? 

Spring boot actuator is one of the important functions of spring start frame. Spring boot monitor can help you access the current status of production applications running in the environment. There are several indicators must be checked and monitored in a production environment. Even if some external application that may be using these services to trigger alert messages to the relevant personnel. It discloses a monitor module can be used directly as a set of endpoints REST HTTP URL accessed to check the status.

Question six

How to disable Actuator endpoint security in Spring Boot in? 

By default, all sensitive HTTP endpoints are secure, only users with ACTUATOR role can access them. Security is implemented using the standard method of HttpServletRequest.isUserInRole. We can use

management.security.enabled = false

To disable security. Only when the actuator endpoint access behind a firewall, it is recommended to disable security.

Question seven

How to run Spring Boot application on a custom port? 

Spring Boot To run the application on a custom port, you can specify the port in the application.properties.

server.port = 8090

Question eight

What is YAML? 

YAML is a human-readable language data sequence. It is commonly used configuration files.

Compared with the properties file, if we want to add complicated properties in the configuration file, YAML file is more structured and less confusion. It can be seen YAML have a layered configuration data.

Nine on

How security is implemented Spring Boot application? 

In order to achieve the security of Spring Boot, we use spring-boot-starter-security dependencies, and you must add security configuration. It requires very little code. The configuration class must extend WebSecurityConfigurerAdapter and covering its methods.

Question 10

How to integrate Spring Boot and ActiveMQ? 

For integrated Spring Boot and ActiveMQ, we use

spring-boot-starter-activemq

Dependencies. It requires very little configuration, and does not require boilerplate code.

Question 11

How to use Spring Boot implement paging and sorting? 

Use Spring Boot implement paging is very simple. Use Spring Data-JPA can achieve pageable

org.springframework.data.domain.Pageable

Passed to the method repository.

Problem 12

What is Swagger? You achieve it with a Spring Boot it? 

Swagger is widely used for visualization API, use Swagger UI online sandbox for the front-end developers. Swagger is a tool for generating visual representation of RESTful Web services, rules and complete framework for implementation. It allows documents to be updated to the server at the same speed. When properly defined by Swagger, consumers can use to achieve a minimal amount of logic to understand and interact with remote services. Therefore, Swagger eliminates the guesswork when calling service.

Thirteen issues

What is Spring Profiles? 

Spring Profiles allows users profile (dev, test, prod, etc.) to register bean. Therefore, when the application runs in development, only some of the bean can be loaded, while in PRODUCTION, some other bean can be loaded. We assume that the requirement is Swagger document applies only to the QA environment, and disable all other documents. This can be done using the configuration file. Spring Boot makes using configuration files is very simple.

Problem fourteen

What is Spring Batch? 

Spring Boot Batch provide reusable functions, these functions are very important when dealing with a large number of records, including logging / tracking, transaction management, job processing statistics, job restart, skipping and resource management. It also provides more advanced technical services and functions, and by optimizing the partitioning technology, can achieve high-performance and high-volume batch jobs. Simple and complex high-volume batch jobs can take advantage of a highly scalable framework for dealing with the way a lot of important information.

Question fifteen

What is FreeMarker template? 

FreeMarker is a Java-based template engine, originally focused on using the MVC software architecture for dynamic page generation. The main advantage of using Freemarker are completely separate layer and business layer. Programmers can handle the application code, and the design can handle html page design. Finally, use freemarker these can be combined to give the final output page.

Question sixteen

How to use Spring Boot achieve exception handling? 

Spring provides a very useful method for abnormal use ControllerAdvice process. We ControlerAdvice by implementing a class to handle all exceptions thrown controller class.

Was the 17

You use what starter maven dependencies? 

Using some of the following dependencies

spring-boot-starter-activemq

spring-boot-starter-security

spring-boot-starter-web

This helps to increase less dependencies, and reduce the release of conflict.

Problem eighteen

What is CSRF attack? 

On behalf of CSRF CSRF. This is an attack, forcing the end user to perform unwanted actions on the current authenticated Web applications. CSRF attacks specifically for the status change request, rather than data theft, because the attacker can not view the response to the request forgery.

Nineteen problem

What is WebSockets? 

WebSocket is a computer communication protocol, provides full-duplex communication channels over a single TCP connection.

1, WebSocket is bi-directional - use WebSocket client or server can initiate a message.

2, WebSocket full duplex - Client and server communication are independent.

3, a single TCP connection - initial connection using HTTP, and then upgrade to this connecting socket-based connection. This single connection is then used for all future communications

4, Light - compared with http, WebSocket message data exchange is much lighter.

The twenty

What is AOP? 

In the software development process across multiple points of application function is called cross-cutting issues. These cross-cutting issues and the main business logic of the application is different. Therefore, to separate these cross-cutting concerns with the local business logic is aspect-oriented programming (AOP) is.

Twenty-first

What is Apache Kafka? 

Apache Kafka is a distributed publish - subscribe messaging system. It is a scalable, fault-tolerant publish - subscribe messaging system, it allows us to build distributed applications. This is a top-level Apache project. Kafka for offline and online news consumption.

Problem twenty-two

How do we monitor all Spring Boot micro service? 

Spring Boot Monitor provides monitoring of endpoint to measure each micro services. These endpoints for access to information about applications (such as whether they have started) and their components (such as databases) is functioning properly helpful. However, a major disadvantage of using a monitor or difficulty is that we have to open a separate application knowledge to understand their condition or state of health. Imagine applications involving 50 micro service, administrators will have to hit all 50 execution terminal applications.

To help us deal with this situation, we will use is located

https://github.com/codecentric/spring-boot-admin

Open source projects. It is built on Spring Boot Actuator, it provides a Web UI, enabling us to visualize multiple measurement applications.

Guess you like

Origin blog.csdn.net/Java_q705127209/article/details/90292920