Spring first program notes

xiaoxiao2021-03-06  44

Springframework download http://www.springframework.org/http://sourceforge.net/project/showfiles.php?group_id=73357 installation seems to be unused, the easiest use as long as the Spring.jar package can be used in the example An example of xiaxin is included in the document http://www.xiaxin.net/spring_dev_guide.rar. Example notes: (a lot from this document) 1. In all of our program code (except for test code), there is no component in spring. 2. The Message property of the Upperaction and LowerAction is dynamically set by Spring By the Read Configuration File (Bean.xml). 3. Customer code (here is our test code) only for interface programming, without having to know the specific name of the class. At the same time, we can simply switch the specific underlying implementation class by modifying the configuration file.

What is mentioned above, what is helpful for our actual development? First, our components do not need to implement the interface specified by the framework, so you can easily disengage the components from Spring, and don't even need any modifications (this is unimaginable in applications based on EJB framework). Second, the dependence between the components is reduced, which greatly improves the reusability of the code.

Spring's dependency injection mechanism can configure the required resources in the run period, without the need to specify when writing component code, thereby reducing the coupling between components to a considerable extent. In the above example, we pass Spring, in the runtime dynamically, injects the string "Hello" into the Message property of the Action implementation class. If you exchange the Message property to a data source (DataSource), the role is more obvious. ----------- The simplest Spring program only needs 2 JAR packages, Spring.jar Commons-logging.jar ----------- Examples of rectification of injection: notebook , USB hard drive, USB U disk, operating system notebook to implement file access via USB interface, regardless of the device's operating system is a container, to determine the notebook to access the notebook according to the actual configuration (in plug-in U disk or mobile hard disk) equipment. The hard disk is reused, and the notebook has also gained the expansion and the PS / 2 keyboard opposite this example. This is that the container is not managed according to the configuration, and the access method is fixed by the motherboard.

The laptop is connected to the peripheral storage device, and for the notebook, for the notebook, only the data specified by the user is sent to the USB interface, and the data is determined by the currently accessible USB device. Before the USB device is loaded, the notebook cannot expect the user to access what device on the USB interface. After the USB device is accessed, the dependency between such devices has begun to form. Corresponding to the above description of the dependency injection mechanism, the dependency (the Windows operating system running in the notebook is loaded) is injected into the component (the Notebook is dependent on the Windows operating system) in the runtime (Windows operating system running in the notebook). Windows file access component). This example has no precise description concept, but it is a certain help to understand this concept ----------- Dependent the target is not to bring more functions to the software system, but to improve the probability of component reuse And build a flexible and scalable platform for the system. ---- Resources ----- There is a Spring Eclipse plugin, providing Spring's bean.xml visual view, but it seems that I didn't find it?) There is no visual editing function, it is recommended for Spring website, The plugin is still perfected.

转载请注明原文地址:https://www.9cbs.com/read-53230.html

New Post(0)