1. What is Spring Boot?

Over the years, Spring has become more complex as new features have been added. Simply visit https://spring.io/projects pages, we’ll see you can use in our application of all the different function of a Spring project. If we had to start a new Spring project, we had to add build paths or Maven dependencies, configure the application server, and add Spring configuration. So starting a new Spring project takes a lot of effort, because we now have to do everything from scratch.
Spring Boot is the solution to this problem. Spring Boot is already built on top of the existing Spring framework. With Spring boot, we avoided all the boilerplate code and configuration that we had to do before. Therefore, Spring Boot can help us use existing Spring functionality more robustly with less effort.

2. What are the advantages of Spring Boot?

The advantages of Spring Boot include:
  • Reduced development, testing time and effort.
  • Using JavaConfig helps you avoid using XML.
  • Avoid massive Maven imports and versioning conflicts.
  • Provide advice on developing methods.
  • Start development quickly by providing default values.
  • No separate Web server is required. This means you no longer need to start Tomcat, Glassfish, or anything else.
  • Less configuration is required because there is no web.xml file. Simply add the class annotated with @Configuration, then add the method annotated with @Bean, and Spring will automatically load the object and manage it as before. You can even add @AutoWired to the bean method to make Spring automatically load the required dependencies.
  • Context-based configuration Using these properties, you can deliver the environment you are using to your application: -dspring.profiles. active = {enviorvulnerabilities}. After loading the main application properties file, Spring loads subsequent application properties files in (Application {environment}.properties).

3. What is JavaConfig?

The Spring JavaConfig is a product of the Spring community that provides pure configuration for the Spring IoC container
Java methods. So it helps to avoid using XML configuration. The advantages of using JavaConfig are:

1. Object-oriented configuration. Because the configuration is defined as a class in JavaConfig, users can take full advantage of Java’s object-oriented capabilities. One configuration class can inherit from another, override its @bean methods, and so on.

Reduce or eliminate XML configuration. The benefits of externalizing configuration based on dependency injection principles have been proven. However, many developers do not want to switch back and forth between XML and Java. JavaConfig provides developers with a pure Java way to configure a Spring container that is similar in concept to XML configuration. Technically, it is possible to configure the container using only the JavaConfig configuration class, but in practice many people think that mixing JavaConfig with XML is ideal.

3. Type safety and refactoring friendly. JavaConfig provides a type-safe way to configure the Spring container. Thanks to Java 5.0 support for generics, beans can now be retrieved by type rather than by name, without any casts or string-based look-ups.

4. How do I reload changes on Spring Boot without restarting the server?

This can be done using the DEV tool. With this dependency, you can save any changes and embedded Tomcat will restart. Spring Boot has a development tools (DevTools) module that helps increase developer productivity. One of the major challenges facing Java developers is automatically deploying file changes to the server and automatically restarting the server. Developers can reload changes on Spring Boot without having to restart the server. This will eliminate the need to manually deploy changes every time. Spring Boot did not have this feature when it released its first version. This is the most desirable feature for developers. The DevTools module fully meets the needs of developers. This module will be disabled in production. It also provides a H2 database console to better test applications.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> Copy the code

5. What is the monitor in Spring Boot?

Spring Boot Actuator is one of the important functions in Spring boot framework. The Spring Boot monitor helps you access the current status of running applications in your production environment. Several metrics must be checked and monitored in the production environment. Even though some external applications may be using these services to trigger alert messages to the people concerned. The monitor module exposes a set of REST endpoints that can be accessed directly as HTTP urls to check status.

6. How to disable THE security of endpoints in Spring Boot?

By default, all sensitive HTTP endpoints are secure, and only users with ACTUATOR roles can access them. Security is the use of standard it. IsUserInRole method implementation. We can use
To disable security. Disabling security is recommended only if an actuator endpoint is accessed behind a firewall.

7. How to run a Spring Boot application on a custom port?

To run Spring Boot applications on custom ports, you can specify ports in application.properties.

server.port = 8090Copy the code

8. What is YAML?

YAML is a human-readable data serialization language. It is usually used for configuration files.
Compared to properties files, YAML files are more structured and less confusing if we want to add complex properties to a configuration file. You can see that YAML has hierarchical configuration data.

How to implement Spring Boot application security?

To implement Spring Boot security, we use the spring-boot-starter-security dependency and must add a security configuration. It requires very little code. Configuration class will must extend WebSecurityConfigurerAdapter and override the method.

10. How to integrate Spring Boot and ActiveMQ?

For integrating Spring Boot and ActiveMQ, we use dependencies. It requires very little configuration and no boilerplate code.

How to use Spring Boot to implement paging and sorting?

Using Spring Boot to implement paging is simple. Using Spring Data-jPA, you can implement paged pass-to-repository methods.

12, What is Swagger? Did you implement it with Spring Boot?

Swagger is widely used in visualization apis, using the Swagger UI to provide an online sandbox for front-end developers. Swagger is a tool, specification, and complete framework implementation for generating visual representations of RESTful Web services. It enables documents to be updated at the same rate as the server. When defined correctly by Swagger, consumers can understand and interact with remote services with minimal implementation logic. Thus, Swagger takes the guesswork out of invoking the service.

13. What are Spring Profiles?

Spring Profiles allows users to register beans against configuration files (dev, test, PROd, etc.). Therefore, when the application is running in development, only certain beans can be loaded, while in PRODUCTION, certain other beans can be loaded. Let’s say our requirement is that the Swagger document only works in the QA environment and all other documents are disabled. This can be done using configuration files. Spring Boot makes using configuration files very simple.

14. What is Spring Batch?

Spring Boot Batch provides reusable functions that are important when handling a large number of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management. It also provides more advanced technical services and capabilities that enable extremely high volume and high performance batch jobs through optimization and partitioning techniques. Both simple and complex bulk batch jobs can leverage the framework to process significant amounts of information in a highly extensible manner.

15. What is a FreeMarker template?

FreeMarker is a Java-based templating engine that initially focused on dynamic web page generation using MVC software architecture. The main advantage of using Freemarker is the complete separation of the presentation layer and the business layer. Programmers can work with application code, while designers can work with HTML page design. Finally, using Freemarker, you can combine these together to give the final output page.

16. How to use Spring Boot to implement exception handling?

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.

17. Which Starter Maven dependencies do you use?

The following dependencies are used

spring-boot-starter-activemq
spring-boot-starter-security Copy the code

This helps to add fewer dependencies and reduce version conflicts.

What is a CSRF attack?

CSRF stands for cross-site request forgery. This is an attack that forces an end user to perform unwanted actions on a currently authenticated Web application. CSRF attacks specifically target state-change requests, not data theft, because the attacker cannot see the response to forged requests.

What are WebSockets?

WebSocket is a computer communication protocol that provides a full-duplex communication channel over a single TCP connection.



  1. WebSocket is bidirectional – a WebSocket client or server can initiate message sending.
  2. WebSocket is full-duplex – client and server communication is independent of each other.
  3. Single TCP connection – The initial connection uses HTTP, then this connection is upgraded to a socket based connection. This single connection is then used for all future communications
  4. Light – WebSocket message data exchange is much lighter than HTTP.

What is AOP?

In software development, functionality that spans multiple points in an application is called a crossover problem. These crossover issues are different from the main business logic of the application. Thus, separating these crosscutting concerns from business logic is where aspect-oriented programming (AOP) comes in.

What is Apache Kafka?

Apache Kafka is a distributed publish-subscribe messaging system. It is an extensible, fault-tolerant publish-subscribe messaging system that enables us to build distributed applications. This is an Apache top-level project. Kafka is suitable for offline and online messaging consumption.

22. How do we monitor all Spring Boot microservices?

Spring Boot provides monitor endpoints to monitor metrics for individual microservices. These endpoints are useful for getting information about applications, such as whether they are started, and whether their components, such as databases, are functioning properly. However, one of the major disadvantages or difficulties of using monitors is that we have to open the knowledge points of the application separately to understand its state or health. Imagine a microservice that involves 50 applications, and an administrator would have to hit the execution terminals for all 50 applications.
To help us deal with this situation, we will use the open source project located in. Built on top of Spring Boot Actuator, it provides a Web UI that enables us to visualize metrics for multiple applications.

Conclusion:

【 Prepare for spring recruitment series 】50 micro service interview questions in detail

【 Prepare for spring recruitment series 】27 MyBatis interview real questions detailed explanation

Q: How do you nail an interviewer

Spring recruitment is coming, sorted out some classic interview questions often tested by big factory, friends in need can pay attention to wechat public number: Java Programmers gathering place.