Spring common face question

Source: Internet
Author: User
Tags aop

This article is through the collection of online interview guide topics and answers and then summarized, just to facilitate later review, not to offend the original author.

1. What is Spring?

Spring is an open-source development framework for Java Enterprise applications. Spring is primarily used to develop Java applications, but some extensions are for Web applications that build the EE platform. The Spring framework goal is to simplify Java enterprise application development and promote good programming habits through the Pojo-based programming model.

2. What are the benefits of using the spring framework?
    • Lightweight: Spring is lightweight, with a basic version of about 2MB.
    • Control inversion: Spring is loosely coupled through control inversion, and objects are given their dependencies rather than creating or locating dependent objects.
    • Aspect-oriented programming (AOP): Spring supports tangent-oriented programming and separates application business logic from system services.
    • Containers: Spring contains and manages the life cycle and configuration of objects in your app.
    • MVC framework: Spring's web Framework is a well-designed framework and a good alternative to web frameworks.
    • Transaction management: Spring provides a continuous transaction management interface that can be extended up to the local transaction down to the global transaction (JTA).
    • Exception handling: Spring provides a convenient API for translating specific technology-related exceptions (such as those thrown by jdbc,hibernate or JDO) into a consistent unchecked exception.
3. What modules does the Spring framework have?
    • Spring Core container: A container is the core part of the spring framework that manages the creation, configuration, and management of beans in spring applications.
    • Spring AOP module: In this module, Spring provides rich support for aspect-oriented programming.
    • Data access and integration
    • Web and Remote Calls
    • Instrumentation
    • Test
4. What is the difference between beanfactory and ApplicationContext?

Beanfactory and ApplicationContext are different implementations of spring containers, which are responsible for creating objects, assembling them, configuring them, and managing their entire lifecycle.
Beanfactory is the simplest container that provides basic DI support, ApplicationContext builds on Beanfactory and provides application framework-level services, such as parsing text information from a property file and publishing application time to interested event listeners.

5. Common ApplicationContext implementation methods?
    • Annotationconfigapplicationcontext: Loads the spring application context from one or more Java-based configuration classes.
ApplicationContext context = new AnnotationConfigApplicationContext(com.springinaction.server.config.ServerConfig.class);
    • Classpathxmlapplicationcontext: Loads the context definition from one or more XML configuration files under the classpath, using the definition file of the application context as the class resource.
ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
    • Filesystemxmlapplicationcontext: Loads the context definition from one or more XML configuration files under the file system.
ApplicationContext context = new FileSystemXmlApplicationContext("c:/bean.xml");
    • Xmlwebapplicationcontext: Loads the context definition from one or more XML configuration files under the Web application.

Spring common face question

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.