Spring Face questions

Source: Internet
Author: User

  1. What is Spring

    • Spring is a lightweight container that implements the IOC and non-intrusive framework and provides the implementation of the AOP, providing support for the persistence layer, which allows the Java development to be modular and run through the persistence layer, the logic layer, the presentation layer, so that each module can be separated independently, reduce the coupling, improve the code reuse rate .
  2. The benefits of Spring

    • Spring provides IOC and DI, handing over the work of managing and maintaining objects to the spring

    • Spring is more lightweight

    • Spring does not repel other frameworks, so other frameworks and spring integration become easy

    • Spring provides the SPRINGMVC

    • Spring provides convenient transaction control

  3. Springioc and Di

    • IOC is handing over to spring the work of maintaining objects and creating objects instead of creating and maintaining them ourselves.

    • DI is the desired attribute in the injected object

  4. Three ways to Di

    • Construction method

    • Set method

    • Interface

  5. The difference between beanfactory and ApplicationContext

    • First Beanfactory and ApplicationContext are interfaces, and ApplicationContext is the sub-interface of Beanfactory.

    • The second beanfactory is the lowest interface in spring, providing the simplest container functionality, providing only the ability to instantiate objects and take objects.

    • ApplicationContext (Application context) It is a more advanced container of spring, provides more useful functionality, ApplicationContext inherits the Beanfactory interface, so, ApplicationContext can also get beans (inherited to listablebeanfactory) like beanfactory from a container.

    • Loading in different ways, Beanfactory uses deferred loading as a way to inject beans, that is, only when a bean is used, the bean is loaded and instantiated.

    • ApplicationContext, on the other hand, creates all the beans at once when the IOC is easy to start,

  6. Common ways to implement ApplicationContext

    • Classpathxmlapplicationcontext

    • Filesystemxmlapplicationcontext

    • Xmlwebapplicationcontext

  7. Scope of Springbean

    • Singleton Single case

    • Prototype Multiple Cases

    • In the request request life cycle

    • During the session session life cycle

    • Global-session

  8. Annotated way to configure beans

    • Set in the spring configuration file<context:annotation-config/>

    • @Autowired to match by type

    • @Qualifier ("student") to match by ID

    • @Resource (name= "student")//parameters are matched with parameters and IDs, and if not, use the variable name and ID first, then match the type

  9. The default one bean is initialized in the spring container, and if set to Lazy-init or other scopes, it will be initialized when the bean is used (init, destory)

  10. What is spring inner beans

    • That is, the spring internal Bean, which defines another bean within one bean
  11. Spring Event (5)

    • Context Update event (contextrefreshedevent): The event is published when ApplicationContext is initialized or updated. It can also be triggered when the refresh () method in the Configurableapplicationcontext interface is called.

    • Context start Event (contextstartedevent): triggered when the container is called by the Configurableapplicationcontext Start () method to begin/Restart the container.

    • Context stop event (contextstoppedevent): This event is triggered when the container invokes the Stop () method of Configurableapplicationcontext.

    • Context Shutdown event (contextclosedevent): This event is triggered when ApplicationContext is closed. When a container is closed, all the singleton beans it manages are destroyed.

    • Request processing event (Requesthandledevent): In a web App, the event is triggered when an HTTP request (request) ends.

    • Allows users to customize events, inherit Applicationevent, and also create a listener

  12. With those design patterns.

    • Proxy mode-much more is used in AOP and remoting.

    • Singleton mode-The bean defined in the spring configuration file defaults to singleton mode

    • Template method-Used to solve the problem of code duplication.

    • The front-end controller-spring provides dispatcherservlet to distribute the request.

    • The Factory mode-beanfactory is used to create an instance of an object.

    • Dependency Injection-The core concept that runs through the Beanfactory/applicationcontext interface.

    • Views Help (View helper)

  13. Aop

    • Simplify code by separating common code from the business. Using the JDK agent and cglib agent

    • Connection points: Before and after the execution of a method and throwing an exception can be used as a connection point, where it will be enhanced and connected to the target method.

    • Pointcut: When a method is called, the connection point on this method becomes the Pointcut

    • Enhancement: Target method In addition to the core business of the required methods, such as in the Save () method, Save () as the core method, the open transaction as a non-core method, can be drawn out, in the AOP open transaction is called enhanced

    • Facets: Classes other than the class in which the target method resides

    • Proxy: Combine target methods with enhancements

    • Weaving: The process of generating a proxy class

  14. Transaction

    • Spring built-in transaction manager, configuration is good

    • There are two methods of configuration and declarative

Spring Face questions

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.