Current location - Education and Training Encyclopedia - Education and training - Java Core Technology: What is Spring?
Java Core Technology: What is Spring?
From the point of view of simplicity, testability and loose coupling, any Java application can benefit from Spring. Simply put, Spring is a lightweight container framework that controls inversion (IoC) and aspect-oriented (AOP). Let's understand the main features of Spring as a whole: * Lightweight: Spring is lightweight in size and cost. In addition, Spring is non-intrusive: with Spring, our class is still a pojo class, and there is no need to inherit and implement Spring's classes and interfaces. In other words, objects in applications that use Spring do not depend on specific classes of Spring. *IoC:Spring promotes loose coupling by controlling inversion technology. When IoC is applied, other objects on which an object depends will be passed in passively, instead of creating or looking for the dependent objects by the object itself. It can be thought that IoC is the opposite of JNDI-we don't control the object to find the dependency from the container itself, but the container actively passes the dependency to the object at initialization, which is DI-dependency injection. Basically, objects don't have to be managed and created by themselves. Completely managed by the container, we just use it. *AOP:Spring provides aspect-oriented programming support. AOP separates and extracts the content irrelevant to the program business, and the application object only realizes what it should do-completing the business logic-and that's all. They are not responsible for other system-level issues, such as logging or transaction support. AOP cuts business-independent logic into real logic. * Framework: Spring can combine simple component configurations into complex applications. In Spring, application objects are combined declaratively, usually in an XML file. Spring also provides many basic functions (transaction management, persistence framework integration and so on). ), users have more time and energy to develop application logic. All these features of Spring can help us write cleaner, easier to manage and easier to test code. They also provide basic support for various modules in Spring. * With the help of Spring, Guo Rong dependency injection, AOP application and interface-oriented programming, the coupling between business components is reduced and the system scalability is enhanced. :: Make existing technologies and frameworks easier to use. * Using hibernate's SessionFactory and transaction management package, Hibernate can be applied more concisely. * Spring is not completely dependent on Spring, and developers are free to choose part or all of the Spring framework. * With AOP, we can focus on business logic, reduce duplicate code and build elegant solutions. * Low-invasive design, extremely low code pollution. Spring is committed to the solutions of J2EE applications at all levels, not just focusing on the solutions of a certain layer. It can be said that Spring is a "one-stop" choice for enterprise application development, which runs through the presentation layer, business layer and persistence layer. Although Spring can solve the whole project problem in one stop, Spring does not want to replace those existing frameworks, but integrates seamlessly. Spring can reduce the difficulty of using various frameworks, and it directly supports various excellent frameworks (such as Struts, Hibernate, Hessian, Quartz, etc.). The main purpose of using Spring is to make J2EE easy to use and promote good programming habits, and the goal of Spring is to make existing technologies easier to use. So an important idea of Spring is integration and compatibility.