In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the interview questions of the Java Spring framework?" in the operation of the actual case, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. What is the MVC framework of Spring?
Answer: Spring is equipped with a full-featured MVC framework for building Web applications. Spring can be easily integrated with other MVC frameworks, such as Struts,Spring 's MVC framework, which clearly separates business objects from control logic with control reversals. It also allows you to bind request parameters to business objects declaratively.
2. What are the benefits of using the Spring framework?
Answer:
Lightweight: Spring is lightweight, and the basic version is about 2MB.
Control inversion: Spring achieves loose coupling through control inversion, and objects give their dependencies instead of creating or finding dependent objects.
Aspect-oriented programming (AOP): Spring supports aspect-oriented programming and separates application business logic from system services.
Containers: Spring contains and manages the lifecycle and configuration of objects in the application.
MVC framework: Spring's WEB framework is a well-designed framework and a good alternative to the Web framework.
Transaction management: Spring provides a continuous transaction management interface that can be extended from local transactions down to global transactions (JTA).
Exception handling: Spring provides convenient API to convert specific technology-related exceptions (such as those thrown by JDBC,Hibernate or JDO) into consistent unchecked exceptions.
3. Explain JDBC abstraction and DAO module.
Answer: by using JDBC abstraction and DAO module, we can keep the database code concise and avoid the problems caused by the wrong closure of database resources. it provides a unified exception access layer based on the error messages of different databases. It also uses the AOP module of Spring to provide transaction management services to objects in Spring applications.
4. Explain the object / relational mapping integration module.
Answer: by providing the ORM module, Spring enables us to use an object / relational mapping (ORM) tool on top of direct JDBC, and Spring supports the integration of mainstream ORM frameworks such as Hiberate,JDO and iBATIS SQLMaps. Spring's transaction management also supports all of the above ORM frameworks and JDBC.
5. What are the advantages of IOC?
Answer: IOC or dependency injection minimizes the amount of code in the application. It makes applications easy to test, and unit testing no longer requires singletons and JNDI lookup mechanisms. Loose coupling can be achieved with minimum cost and minimum intrusiveness. The IOC container supports hungry initialization and lazy loading when loading services.
6. What's the difference between Bean factory and Application contexts?
Answer: Application contexts provides a way to handle text messages. A common practice is to load file resources (such as images) that can publish events to bean registered as listeners. In addition, operations performed on containers or objects within containers that have to be handled programmatically by the bean factory can be handled declaratively in Application contexts. Application contexts implements the MessageSource interface, whose implementation provides a way to get localized messages in a pluggable manner.
7. What is dependency injection for Spring?
Answer: dependency injection, an aspect of IOC, is a common concept with many interpretations. The concept means that you don't have to create an object, you just need to describe how it is created. You do not assemble your components and services directly in the code, but describe which components need which services in the configuration file, and then a container (IOC container) is responsible for assembling them.
8. How do you define the scope of a class?
Answer: when defining one in Spring, we can also declare a scope for the bean. It can be defined by the scope attribute in the bean definition. For example, when Spring wants to produce a new bean instance each time it is needed, the scope property of bean is specified as prototype. On the other hand, a bean must return the same instance every time it is used, and the scope property of this bean must be set to singleton.
9. What are the important bean lifecycle approaches? Can you reload them?
Answer: there are two important bean lifecycle methods. The first is setup, which is called when the container loads the bean. The second method is teardown, which is called when the container unloads the class. The The bean tag has two important attributes (init-method and destroy-method). With them you can customize your own initialization and logout methods. They also have corresponding annotations (@ PostConstruct and @ PreDestroy).
10. How to inject a java collection into Spring?
Answer: Spring provides configuration elements for the following collections:
Type is used to inject a list of values, allowing the same value.
Type is used to inject a set of values and the same values are not allowed.
Type is used to inject a set of key-value pairs, both of which can be of any type.
Type is used to inject a set of key-value pairs, and both keys and values can only be of type String.
11. What is annotation-based container configuration?
Answer: compared to XML files, annotated configuration depends on assembling components through byte symbol data, rather than angle bracket declarations. Developers configure the bean directly in the component class by using annotations on the corresponding class, method, or property, rather than using xml to express the assembly relationship of the component.
12. What are the advantages of transaction management in the Spring framework?
Answer: it provides an immutable programming model for different transaction API such as JTA,JDBC,Hibernate,JPA and JDO; it provides a set of simple API rather than some complex transaction API; for programmatic transaction management; it supports declarative transaction management; it integrates well with various data access abstraction layers of Spring.
What is the controller of the Spring MVC framework?
Answer: the controller provides a behavior to access the application, which is usually implemented through the service interface. The controller parses the user input and converts it into a model that is presented to the user by the view. Spring implements a control layer in a very abstract way, allowing users to create multi-purpose controllers.
This is the end of the content of "what are the interview questions for the Java Spring framework". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.