11 frequency Java interview questions parsing (Spring + Spring MVC + MyBatis)

Foreword

Has recently been in the interview, finishing the three framework Several companies face questions frequently asked, the answer now bring it here for everyone to sort out the good news to share, we want to help.

11 frequency Java interview questions parsing (Spring + Spring MVC + MyBatis)

The following is the Spring Common Interview Questions

1. What is Spring Framework? What are the main module Spring framework?

Spring is a framework providing for the comprehensive development of Java applications, broad-based support for the Java platform.

Spring to help developers solve the problem of the development of fundamental, so that developers can focus on application development.

Spring framework itself is also a well-built according to the design mode, which makes the integration of Spring box we can feel at ease in a development environment

Frame, do not worry about how Spring work in the background.

Spring Framework has been integrated in more than 20 modules. These modules are mainly divided core container as shown below, the data access / current

To ,, Web, AOP (Aspect Oriented Programming), tools, modules and test message.

2, using the Spring framework which can bring benefits?

Here are some of the major benefits of using the Spring Framework provides:

Dependency Injection (DI) method such that a dependency JavaBean properties and configuration files

Glance.

Compared with the EJB container, IoC containers tend to be more lightweight. As a IoC container in a limited memory and CPU resources

Develop and publish applications if the source becomes very favorable.

Spring does not closed doors, Spring advantage of existing technology, such as ORM framework, logging framework, J2EE, Q

uartz and JDK Timer, as well as other view technology.

Spring Framework is organized in the form of modules. By the packet number and the class to which it belongs can be seen the module, the developer only

Only need to use the module to their needs.

To test an application using Spring development is very simple, because the test environment-related code have included in the frame

A. More simply, the use of POJO class JavaBean form, can easily be written using a dependency injection test

data.

Web framework Spring Web MVC framework is also a well-designed, the choice of web framework for developers in

It provides a strong addition to an option other than a mainstream framework such as Struts, over-designed, unpopular web framework.

Spring provides a convenient transaction management interface for small local transaction processing (such as in a single DB environment

Under) and complex common transaction processing (such as the use of complex DB JTA environment).

11 frequency Java interview questions parsing (Spring + Spring MVC + MyBatis)

3. What is Inversion of Control (IOC)? What is dependency injection?

Inversion control is applied in the field of software engineering, it is fitted at runtime object to bind a programming object coupling techniques, for

Coupling between at compile time as is generally known. In conventional programming, the process is a business logic application

Has already been set up association objects to the decision. In the case where the inversion of control, business logic by process object relation

FIG determined, which is responsible for assembling object graph instantiation, this implementation may also be associated with the given relationship between objects

Meaning of abstraction. The process is bound by the "dependency injection" to achieve.

Inversion of Control is an application to give more control target component for the purpose of design patterns, and play in our practical work

An effective role.

Dependency injection is not known at compile time function is required in the case of which the class from the other objects in the function depends

Examples of the mode. This requires a mechanism to activate the respective components to provide a particular function, the control dependency injection is trans

Transfer basis. Otherwise, if the components are not in the case of the control framework, the framework and how to know which components you want to create?

In Java is still injection following three ways:

  1. Constructor injection

  2. Setter Method Injection

  3. Interface injection

4, please explain Spring framework IoC?

Spring org.springframework.beans package and the package org.springframework.context

Spring framework forms the basis IoC container.

BeanFactory interface provides an advanced configuration mechanism so that any type of configuration object becomes possible.

ApplicationContex BeanFactory interface (a sub-interface) is extended, in BeanFactory

的基础上添加了其他功能,比如与 Spring 的 AOP 更容易集成,也提供了处理 message resource

的机制(用于国际化)、事件传播以及应用层的特别配置,比如针对 Web 应用的

WebApplicationContext。

org.springframework.beans.factory.BeanFactory 是 Spring IoC 容器的具体实现,

用来包装和管理前面提到的各种 bean。BeanFactory 接口是 Spring IoC 容器的核心接口。

IOC:把对象的创建、初始化、销毁交给 spring 来管理,而不是由开发者控制,实现控制反转。

11 frequency Java interview questions parsing (Spring + Spring MVC + MyBatis)

以下为 Spring MVC常见面试问题

1、什么是 Spring MVC?

答:SpringMvc 是 spring 的一个模块,基于 MVC 的一个框架,无需中间整合层来整合。

2、Spring MVC 的优点:

答:

1)它是基于组件技术的.全部的应用对象,无论控制器和视图,还是业务对象之类的都是 java

组件.并且和 Spring 提供的其他基础结构紧密集成.

2)不依赖于 Servlet API(目标虽是如此,但是在实现的时候确实是依赖于 Servlet 的)

3)可以任意使用各种视图技术,而不仅仅局限于 JSP

4)支持各种请求资源的映射策略

5)它应是易于扩展的

3、SpringMVC 工作原理?

答:

1)客户端发送请求到 DispatcherServlet

2)DispatcherServlet 查询 handlerMapping 找到处理请求的 Controller

3)Controller 调用业务逻辑后,返回 ModelAndView

4)DispatcherServlet 查询 ModelAndView,找到指定视图

5)视图将结果返回到客户端

11 frequency Java interview questions parsing (Spring + Spring MVC + MyBatis)

以下为 MyBatis 常见面试问题

1、什么是 MyBatis?

答:MyBatis 是一个可以自定义 SQL、存储过程和高级映射的持久层框架。

2、讲下 MyBatis 的缓存

A: MyBatis cache into cache and secondary cache, cache session on the inside, there is a default, two slow

Stored in its name space, the default is not open, requires using secondary cache attribute class implements Serializable Serialized

Interface (used to save the state of the object), it may be disposed on mapping file <cache />

3, Mybatis how to page through? What is the principle pagination plug-in?

answer:

1) Mybatis use RowBounds objects page, you can also write directly sql implement paging, you can use

Mybatis pagination plug-in.

2) the principle of pagination plug-in: implementation of the interface Mybatis provided, implement a custom plug-in, stopped in the plug-ins to intercept method

Cut sql to be executed, and then rewrite the sql.

Example: SELECT from Student, intercepting sql rewritten as:. SELECT T from (SELECT * from Student) T

limit 0,10

4, operating principles outlined Mybatis plug-ins, as well as how to write a plugin?

answer:

1) Mybatis only be written for ParameterHandler, ResultSetHandler, StatementHandler,

Executor these four plug interface, Mybatis dynamic proxies, to generate the interface proxy object in real need to intercept

Now the interface method interception function, method executes whenever these four interface objects, will enter the intercept method is specific

InvocationHandler the invoke () method, of course, will only need to intercept those you specify interception.

2) achieve Mybatis the Interceptor interfaces and replication intercept () method, and then write notes to the plug-in, specify

To which one interface which can intercept method, remember, do not forget to configure the plugin that you write in the configuration file.

Guess you like

Origin blog.51cto.com/14442094/2422547