Hikvision java expert post phone interview

1. How do you transform a single application into a microservice architecture?
2. The startup principle of spring boot and its core components ( Analysis of the most common questions in interviews: Spring Boot ) ( Recommended in the book recommended "Spring Boot practice" send")

  1. Create a SpringApplication instance
  2. Call the run(args) method of this SpringApplication instance:
    1. 1 prepareEnvironment
    2. 2 refreshContext(context)

3. The automatic assembly of spring boot and how its beans are loaded

The description of automatic assembly in Spring Boot official documents:

Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For example, if HSQLDB is on your classpath, and you have not manually configured any database connection beans, then Spring Boot auto-configures an in-memory database.

Also:

SpringBoot defines a set of interface specifications. This set of specifications stipulates: When SpringBoot starts, it scans the META-INF/spring.factories file in the external reference jar package, and loads the type information configured in the file into the Spring container (here involved JVM class loading mechanism and Spring's container knowledge), and perform various operations defined in the class. For external jars, you only need to install your own functions into SpringBoot according to the standards defined by SpringBoot.

To put it simply, Spring Boot auto-wiring is dedicated to automatically configuring your Spring application based on the dependencies you add, using conditional annotations (@Conditional).
Specifically, the @EnableAutoConfiguration annotation imports the AutoConfigurationImportSelector class through the @Import annotation. The AutoConfigurationImportSelector can return all the information of the auto configuration class in the form of a List through the SPI mechanism (specifically, the getCandidateConfigurations method). These configuration information will be managed by the Spring container as a bean. The role of conditional annotations is to dynamically select beans that meet the conditions when the application is running. For example, the following @ConditionalOnClass(xxx.class) is used to load the configuration class when it is judged that there is a xxx class during the loading process. The following is the automatic assembly class that introduces mvc components.

@Configuration
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass({
    
     Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class })
@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10)
@AutoConfigureAfter({
    
     DispatcherServletAutoConfiguration.class,
        TaskExecutionAutoConfiguration.class, ValidationAutoConfiguration.class })
public class WebMvcAutoConfiguration {
    
    

4. How to optimize elasticsearch. I found an example on the Internet: Look at Elasticsearch optimization through a real case

5. Comparative analysis of the advantages and disadvantages of tomcat and jetty: refer to https://developer.ibm.com/zh/articles/j-lo-jetty/ , https://www.cnblogs.com/lixuwu/p/10817557.html :

tomcat jetty
Lighter
More bloated, the overall design is more complicated, Tomcat's design ranges from Server to Service to engine and other container containers In terms of architecture, it is simpler and more flexible, based on Handler, and the responsibility chain model is easy to extend and plug, that is, components can be loaded on demand, and unnecessary components can be reduced.
After a long period of development, Tomcat has been widely accepted and recognized by the market. Compared with Jetty, Tomcat is still relatively stable and mature. Especially in enterprise-level applications, Tomcat is still the first choice.
Tomcat uses BIO to handle I/O requests by default Jetty uses NIO to handle I/O requests by default
Tomcat is currently widely used, with more comprehensive support for JavaEE and Servlet Jetty is simple to modify and supports the new Servlet specification better.

6. Mybatis dynamic sql
Mybatis dynamic sql allows us to write dynamic sql in the form of tags in the Xml mapping file to complete the function of logical judgment and dynamic splicing of sql. For example, Chen Wei's dynamic SQL

Guess you like

Origin blog.csdn.net/qq_23204557/article/details/114695371