What is Spring? Simply put, it is an open-source framework and a lightweight Enterprise Application Development Framework. You can use a simple JavaBean to replace the original EJB work. What is the concept that Spring has to talk about? DI (dependency injection)-a technology used to solve the coupling problem. It provides loose coupling between objects. when an object is instantiated, injection of related dependent classes is active, rather than passive searching. The dependency between objects is not hard-coded, but assembled through XML files. AOP (Aspect-Oriented) is to separate specific general applications from the business logic and do their respective professional tasks. In fact, like writing a program in C, we will separate common logs and monitoring functions into modules. However, in SPRING, such associations are also managed through XML files. What can Spring do? 1. Spring is a bean container that can manage all bean.2. The architecture SSH we usually use is to use Spring's container management and thing management functions, which can be inherited from multiple ORM modules. 3 SpringMVC is also a solution to replace SSH. in short, we can use it to build various enterprise applications, unless your enterprise applications are very complex, such as banking. the General website platform is sufficient. examples of DI applications in enterprise applications: DI applications are more representative of the concept of interface-oriented programming. The biggest advantage is loose coupling. For example, if you want to write an online ordering application, you need an Order Service Group to create a function to process all order-related functions. We usually have several methods: 1. instantiate a component as needed; 2. Retrieve the service interface through JNDI if the service is implemented through EJB2.0; 3. if the service is implemented through EJB3, you can directly access this issue through JNDI without using the primary interface. You can use the DI application to see it:
Public
ClassCheckout {
PrivateOrderservice;
PublicOrderservice getOrderservice (){
ReturnOrderservice ;}
Public
VoidSetOrderservice (Orderservice orderservice) {Orderservice = orderservice ;}} applicationContext. <bean id = "Checkout" name = "/Checkout" class = "Checkout" abstract = "false" lazy-init = "default" autowire = "default" dependency-check = "default"> <property name = "Orderservice"> <ref bean = "Orderservice"/> </property> </bean> the injection is assembled in XML. of course, the interface-oriented technology should be used here, that is, Orderservice is an interface, which can be any implementation of this interface during assembly, so that it is completely loosely coupled.
This article from the "Breeze" blog, please be sure to keep this source http://miao7616.blog.51cto.com/3258248/675329